import axios from 'axios'; import { FormEvent } from 'react'; import { NavBar } from '../components/navbar'; import { CenteredPage } from '../components/page'; import { Vierkant, Input, Button } from '../components/ui'; function submitLogin(event?: FormEvent) { event.preventDefault(); var formData = { email: (document.getElementById("email") as HTMLInputElement).value, password: (document.getElementById("password") as HTMLInputElement).value } if ( !formData.email || !formData.password ) { alert("Vul alsjeblieft alle velden in!"); return; } axios({ method: "post", url: `${window.location.origin}/api/auth/login`, headers: {"content-type": "application/json"}, data: formData }) .then(() => window.location.pathname = "/") .catch(error => { if (error.response.status === 401) { alert("Verkeerde gebruikersnaam/wachtwoord combinatie!") return; } alert("Er is iets fout gegaan!"); }); } export default function LoginPage() { return (
); }