export default { form: null, display(){ if(this.form === null){ this.form = document.querySelector("#adminCreatePage form"); this.form.addEventListener("submit", (event)=>{ this.submit(event); }); } document.getElementById("adminCreateName").focus(); }, async submit(event){ event.preventDefault(); const body = { name: document.getElementById("adminCreateName").value, email: document.getElementById("adminCreateEmail").value, password: document.getElementById("adminCreatePass").value, confirm_password: document.getElementById("adminCreatePassConf").value }; const response = await fetch("/admin/first", { method: "POST", headers: {"Content-Type": "application/json"}, credentials: "include", body: JSON.stringify(body) }); const data = await response.json(); if(!response.ok) return notify("error", data.msg); openPage("login"); } }