import { client, navigateTo } from "../../index.js"; import { clear, fill_errors } from "../../utils/formUtils.js"; import AbstractNonAuthentifiedView from "../AbstractNonAuthentified.js"; async function login() { let username = document.getElementById("username-input").value; let password = document.getElementById("password-input").value; let response_data = await client.login(username, password); if (response_data == null) { navigateTo("/home"); return; } clear("innerHTML", ["username", "user", "password"]); fill_errors(response_data, "innerHTML"); } export default class extends AbstractNonAuthentifiedView { constructor(params) { super(params, "Login", "/home"); } async postInit() { document.getElementById("login-button").onclick = login; } async getHtml() { return `
`; } }