1
0
Fork 0

Add typing to SetVaultURL.ts.

This commit is contained in:
Kitteh 2021-05-08 01:54:38 +01:00
parent 57a0ab5abe
commit f1ba0a06ce
3 changed files with 11 additions and 10 deletions

View file

@ -10,7 +10,7 @@ import { MePage } from "./pages/Me";
import { NewTOTPPage } from "./pages/TOTP/NewTOTP.js";
import { Page } from "./types/Page";
import { PwGenPage } from "./pages/PwGen";
import { SetLanguagePage } from "./pages/SetLanguage.js";
import { SetLanguagePage } from "./pages/SetLanguage";
import { SetVaultURLPage } from "./pages/SetVaultURL.js";
import { TOTPViewPage } from "./pages/TOTP/TOTPView.js";
import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.js";

View file

@ -2,18 +2,19 @@ import { Margin } from "../elements/Margin";
import { Page } from "../types/Page";
import { changePage, setPageContent } from "../pageUtils";
import { makeElement } from "../htmlUtils";
import { pageState } from "../globalPageState.ts";
import { pageState } from "../globalPageState";
import i18next from 'i18next';
// @ts-ignore
import translations from "../translations/index.mjs";
let languageIDs = Object.getOwnPropertyNames(translations);
const languageIDs = Object.getOwnPropertyNames(translations);
export class SetLanguagePage extends Page {
constructor() {
super();
}
render() {
let setLanguageForm = makeElement({
render(): void {
const setLanguageForm = makeElement({
tag: "form",
id: "setLanguageForm",
children: [
@ -46,12 +47,12 @@ export class SetLanguagePage extends Page {
}
})
]
});
}) as HTMLFormElement;
setPageContent(setLanguageForm);
setLanguageForm.addEventListener("submit", function (e) {
e.preventDefault();
let formData = new FormData(setLanguageForm);
let language = formData.get("language");
const formData = new FormData(setLanguageForm);
const language = formData.get("language") as string;
pageState.language = language;
console.log(pageState.language);
i18next.changeLanguage(language).then((t) => {
@ -61,7 +62,7 @@ export class SetLanguagePage extends Page {
});
});
}
get name() {
get name(): string {
return i18next.t("set_language_title");
}
}

View file

@ -26,7 +26,7 @@ module.exports = {
},
resolve: {
modules: ['node_modules'],
extensions: ['.tsx', '.ts', '.js'],
extensions: ['.tsx', '.ts', '.js', ".mjs"],
},
module: {