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 { NewTOTPPage } from "./pages/TOTP/NewTOTP.js";
import { Page } from "./types/Page"; import { Page } from "./types/Page";
import { PwGenPage } from "./pages/PwGen"; import { PwGenPage } from "./pages/PwGen";
import { SetLanguagePage } from "./pages/SetLanguage.js"; import { SetLanguagePage } from "./pages/SetLanguage";
import { SetVaultURLPage } from "./pages/SetVaultURL.js"; import { SetVaultURLPage } from "./pages/SetVaultURL.js";
import { TOTPViewPage } from "./pages/TOTP/TOTPView.js"; import { TOTPViewPage } from "./pages/TOTP/TOTPView.js";
import { TransitDecryptPage } from "./pages/Transit/TransitDecrypt.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 { Page } from "../types/Page";
import { changePage, setPageContent } from "../pageUtils"; import { changePage, setPageContent } from "../pageUtils";
import { makeElement } from "../htmlUtils"; import { makeElement } from "../htmlUtils";
import { pageState } from "../globalPageState.ts"; import { pageState } from "../globalPageState";
import i18next from 'i18next'; import i18next from 'i18next';
// @ts-ignore
import translations from "../translations/index.mjs"; import translations from "../translations/index.mjs";
let languageIDs = Object.getOwnPropertyNames(translations); const languageIDs = Object.getOwnPropertyNames(translations);
export class SetLanguagePage extends Page { export class SetLanguagePage extends Page {
constructor() { constructor() {
super(); super();
} }
render() { render(): void {
let setLanguageForm = makeElement({ const setLanguageForm = makeElement({
tag: "form", tag: "form",
id: "setLanguageForm", id: "setLanguageForm",
children: [ children: [
@ -46,12 +47,12 @@ export class SetLanguagePage extends Page {
} }
}) })
] ]
}); }) as HTMLFormElement;
setPageContent(setLanguageForm); setPageContent(setLanguageForm);
setLanguageForm.addEventListener("submit", function (e) { setLanguageForm.addEventListener("submit", function (e) {
e.preventDefault(); e.preventDefault();
let formData = new FormData(setLanguageForm); const formData = new FormData(setLanguageForm);
let language = formData.get("language"); const language = formData.get("language") as string;
pageState.language = language; pageState.language = language;
console.log(pageState.language); console.log(pageState.language);
i18next.changeLanguage(language).then((t) => { 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"); return i18next.t("set_language_title");
} }
} }

View file

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