/// <reference lib="dom" />

import { ok } from "./shared.bundle.ts";

const form = document.getElementById("loginForm") as HTMLFormElement;
const passwordInput = document.getElementById(
    "passwordInput",
) as HTMLInputElement;

form.addEventListener("submit", async (e) => {
    e.preventDefault();

    const password = passwordInput.value;

    const bodyReq = JSON.stringify(
        ok({
            password: password,
        }).toJSON(),
    );

    const response = await fetch("/login", {
        method: "POST",
        headers: { accept: "application/json" },
        body: bodyReq,
    });

    const body = await response.json();

    const a = 8;
});
