// Copyright (C) 2022-present Daniel31x13 // This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 3. // This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. // You should have received a copy of the GNU General Public License along with this program. If not, see . import Link from "next/link"; import { useState } from "react"; import { useRouter } from "next/router"; interface FormData { name: string; email: string; password: string; } export default function () { const router = useRouter(); const [form, setForm] = useState({ name: "", email: "", password: "", }); async function registerUser() { let success: boolean = false; if (form.name != "" && form.email != "" && form.password != "") { await fetch("/api/auth/register", { body: JSON.stringify(form), headers: { "Content-Type": "application/json", }, method: "POST", }) .then((res) => { success = res.ok; return res.json(); }) .then((data) => console.log(data)); if (success) { setForm({ name: "", email: "", password: "", }); router.push("/login"); } } else { console.log("Please fill out all the fields."); } } return (

Linkwarden

setForm({ ...form, name: e.target.value })} className="border border-gray-700 rounded-md block m-2 mx-auto p-2" /> setForm({ ...form, email: e.target.value })} className="border border-gray-700 rounded-md block m-2 mx-auto p-2" /> setForm({ ...form, password: e.target.value })} className="border border-gray-700 rounded-md block m-2 mx-auto p-2" />
Register
Login
); }