2022-01-18 12:06:22 +00:00
|
|
|
import { Button } from "../elements/Button";
|
2022-01-07 14:11:14 +00:00
|
|
|
import { Component } from "preact";
|
2022-01-06 23:02:34 +00:00
|
|
|
import { DefaultPageProps } from "../../types/DefaultPageProps";
|
2022-01-22 13:09:39 +00:00
|
|
|
import { Form } from "../elements/forms/Form";
|
2021-05-24 14:37:37 +01:00
|
|
|
import { Margin } from "../elements/Margin";
|
2022-01-06 18:53:38 +00:00
|
|
|
import { PageTitle } from "../elements/PageTitle";
|
2022-01-06 23:02:34 +00:00
|
|
|
import { route } from "preact-router";
|
2022-01-18 12:06:22 +00:00
|
|
|
import i18next from "i18next";
|
2022-01-22 13:09:39 +00:00
|
|
|
import { TextInput } from "../elements/forms/TextInput";
|
|
|
|
import { InputWithTitle } from "../elements/InputWithTitle";
|
2021-05-24 13:44:36 +01:00
|
|
|
|
2022-01-06 18:53:38 +00:00
|
|
|
export class SetVaultURL extends Component<DefaultPageProps> {
|
|
|
|
render() {
|
|
|
|
return (
|
|
|
|
<>
|
2022-01-18 12:06:22 +00:00
|
|
|
<PageTitle title={i18next.t("set_vault_url_title")} />
|
2022-01-06 23:02:34 +00:00
|
|
|
<Form onSubmit={(data) => this.onSubmit(data)}>
|
|
|
|
<Margin>
|
2022-01-22 13:09:39 +00:00
|
|
|
<InputWithTitle title={i18next.t("set_vault_url_placeholder")}>
|
|
|
|
<TextInput
|
|
|
|
name="vaultURL"
|
|
|
|
placeholder={i18next.t("set_vault_url_placeholder")}
|
|
|
|
required
|
|
|
|
/>
|
|
|
|
</InputWithTitle>
|
2022-01-06 23:02:34 +00:00
|
|
|
</Margin>
|
2022-01-21 21:56:09 +00:00
|
|
|
|
2022-01-06 23:02:34 +00:00
|
|
|
<Margin>
|
2022-01-18 12:06:22 +00:00
|
|
|
<Button text={i18next.t("set_vault_url_set_btn")} color="primary" type="submit" />
|
2022-01-06 23:02:34 +00:00
|
|
|
</Margin>
|
|
|
|
</Form>
|
2022-01-06 18:53:38 +00:00
|
|
|
</>
|
2021-05-24 13:44:36 +01:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
async onSubmit(data: FormData): Promise<void> {
|
2022-01-06 18:53:38 +00:00
|
|
|
// TODO: check if vault is actually working here.
|
2022-01-07 14:26:21 +00:00
|
|
|
this.props.settings.apiURL = data.get("vaultURL") as string;
|
2022-01-06 23:02:34 +00:00
|
|
|
route("/");
|
2021-05-24 13:44:36 +01:00
|
|
|
}
|
|
|
|
}
|