import { showLoading } from "utils/ui.ts"; interface HomeBarProps { name: string; } const settingsData: { [key: string]: string } = {}; export default function HomeBar(props: HomeBarProps) { const doNewPost = async () => { showLoading(); const resp = await fetch("/api/post", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ title: "", content: "", }), }); const respJson = await resp.json(); if (respJson.success) { location.href = `/${respJson.data}`; return true; } return false; }; const doLogout = async () => { const resp = await fetch("/api/user/logout"); const respJson = await resp.json(); if (respJson.success) { location.href = "/login"; return true; } return false; }; const showReset = () => { settingsData["old"] = ""; settingsData["new"] = ""; settingsData["repeat"] = ""; window.$modal?.show( "Reset password",