signup form submission from popup
server needs work to support properly
This commit is contained in:
@@ -2,11 +2,17 @@ import { API_URL, send_message_to_background } from "./common.js"
|
||||
|
||||
const login_form = document.getElementById("login-form") as HTMLFormElement
|
||||
const login_status = document.getElementById("login-status")
|
||||
|
||||
const signup_form = document.getElementById("signup-form") as HTMLFormElement
|
||||
|
||||
if (localStorage.getItem("accessToken")) {
|
||||
login_status.setAttribute("style", "visibility: visible;")
|
||||
}
|
||||
|
||||
login_form.addEventListener("submit", (event) => { event.preventDefault(); submit_login_form() })
|
||||
|
||||
signup_form.addEventListener("submit", (event) => { event.preventDefault(); submit_signup_form() })
|
||||
|
||||
async function submit_login_form() {
|
||||
|
||||
const login_url = new URL("/login", API_URL)
|
||||
@@ -31,4 +37,20 @@ async function submit_login_form() {
|
||||
else {
|
||||
//bad login, update the form
|
||||
}
|
||||
}
|
||||
|
||||
async function submit_signup_form() {
|
||||
const signup_url = new URL("/signup", API_URL)
|
||||
|
||||
const request = new Request(signup_url, {
|
||||
method: "POST",
|
||||
body: new FormData(signup_form)
|
||||
})
|
||||
|
||||
const response = await fetch(request)
|
||||
|
||||
console.log(response)
|
||||
if (response.ok) {
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user