1
0
Fork 0
VaultUI/src/ui/pages/SetVaultURL.tsx

42 lines
1.3 KiB
TypeScript
Raw Normal View History

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";
import { Form } from "../elements/forms/Form";
2021-05-24 14:37:37 +01:00
import { Margin } from "../elements/Margin";
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";
import { TextInput } from "../elements/forms/TextInput";
import { InputWithTitle } from "../elements/InputWithTitle";
2021-05-24 13:44:36 +01: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>
<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-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>
</>
2021-05-24 13:44:36 +01:00
);
}
async onSubmit(data: FormData): Promise<void> {
// 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
}
}