1
0
Fork 0

Add tsx syntax to SetVaultURL.

This commit is contained in:
Kitteh 2021-05-24 13:44:36 +01:00
parent ead00aaef6
commit ed26eba220
2 changed files with 42 additions and 52 deletions

View file

@ -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
View 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";
}
}