import {useState} from 'react' import {Link} from 'react-router-dom' import './InputForm.css'; import {registerUser} from '../services/PhpApi'; import { PasswordInput, Stack, TextInput } from '@mantine/core'; import { CheckCircledIcon, CrossCircledIcon, ExclamationTriangleIcon } from '@radix-ui/react-icons'; import { showNotification } from '@mantine/notifications'; const Register = () => { const [formData, setFormData] = useState({ email:'', password:'', password2:'' }); const onChangeInput = (e: React.FormEvent ) => { setFormData({ ...formData, [e.currentTarget.name]:e.currentTarget.value }) } const submitForm = async (e: React.FormEvent) => { e.preventDefault(); if(!Object.values(formData).every(val => val.trim() !== '')) { showNotification( { icon:
, color: 'orange', message: 'Bitte alle Felder ausfüllen!' }); return; } if(formData.password !== formData.password2) { showNotification( { icon:
, color: 'orange', message: 'Bitte 2mal das gleiche Passwort eingeben!' }); return; } const data = await registerUser(formData); if(data.success) { showNotification( { icon:
, color: 'green', message: 'Erfolgreich Registriert!' }); e.currentTarget.reset(); } else if(!data.success && data.message) { showNotification( { icon:
, color: 'red', message: data.message }); } } return (

Register

Login
) } export default Register;