Add tsx syntax to SetVaultURL.
This commit is contained in:
parent
ead00aaef6
commit
ed26eba220
|
@ -1,52 +0,0 @@
|
||||||
import { Form } from "../elements/Form";
|
|
||||||
import { Page } from "../types/Page";
|
|
||||||
import { makeElement } from "z-makeelement";
|
|
||||||
|
|
||||||
export class SetVaultURLPage extends Page {
|
|
||||||
constructor() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
async render(): Promise<void> {
|
|
||||||
await this.router.setPageContent(
|
|
||||||
Form(
|
|
||||||
[
|
|
||||||
makeElement({
|
|
||||||
tag: "div",
|
|
||||||
class: "uk-margin",
|
|
||||||
children: makeElement({
|
|
||||||
tag: "input",
|
|
||||||
class: ["uk-input", "uk-form-width-medium"],
|
|
||||||
attributes: {
|
|
||||||
required: "true",
|
|
||||||
type: "text",
|
|
||||||
placeholder: "Vault URL",
|
|
||||||
name: "vaultURL",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
}),
|
|
||||||
makeElement({
|
|
||||||
tag: "p",
|
|
||||||
id: "errorText",
|
|
||||||
class: "uk-text-danger",
|
|
||||||
}),
|
|
||||||
makeElement({
|
|
||||||
tag: "button",
|
|
||||||
class: ["uk-button", "uk-button-primary"],
|
|
||||||
text: "Set",
|
|
||||||
attributes: {
|
|
||||||
type: "submit",
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
async (form: HTMLFormElement) => {
|
|
||||||
const formData = new FormData(form);
|
|
||||||
this.state.apiURL = formData.get("vaultURL") as string;
|
|
||||||
await this.router.changePage("HOME");
|
|
||||||
},
|
|
||||||
),
|
|
||||||
);
|
|
||||||
}
|
|
||||||
get name(): string {
|
|
||||||
return "Set Vault URL";
|
|
||||||
}
|
|
||||||
}
|
|
42
src/pages/SetVaultURL.tsx
Normal file
42
src/pages/SetVaultURL.tsx
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
import { Form } from "../elements/ReactForm";
|
||||||
|
import { Margin } from "../elements/ReactMargin";
|
||||||
|
import { Page } from "../types/Page";
|
||||||
|
import { render } from "preact";
|
||||||
|
|
||||||
|
export class SetVaultURLPage extends Page {
|
||||||
|
constructor() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
async render(): Promise<void> {
|
||||||
|
render(
|
||||||
|
<Form onSubmit={(data) => this.onSubmit(data)}>
|
||||||
|
<Margin>
|
||||||
|
<input
|
||||||
|
class="uk-input uk-form-width-medium"
|
||||||
|
name="vaultURL"
|
||||||
|
type="text"
|
||||||
|
placeholder="Vault URL"
|
||||||
|
required
|
||||||
|
/>
|
||||||
|
</Margin>
|
||||||
|
<p id="errorText" class="uk-text-danger" />
|
||||||
|
<Margin>
|
||||||
|
<button class="uk-button uk-button-primary" type="submit">
|
||||||
|
Set
|
||||||
|
</button>
|
||||||
|
</Margin>
|
||||||
|
</Form>,
|
||||||
|
|
||||||
|
this.router.pageContentElement,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
async onSubmit(data: FormData): Promise<void> {
|
||||||
|
this.state.apiURL = data.get("vaultURL") as string;
|
||||||
|
await this.router.changePage("HOME");
|
||||||
|
}
|
||||||
|
|
||||||
|
get name(): string {
|
||||||
|
return "Set Vault URL";
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in a new issue