import { t } from 'i18next'; import { useCallback } from 'react'; import { toast, Toaster } from 'sonner'; import useAuth from '../hooks/useAuth'; const getValue = (id: string): string => { const element = document.getElementById(id); return element instanceof HTMLInputElement ? element.value : ''; }; export const Register = () => { const { register } = useAuth(); const handleSubmit = useCallback( (event: React.FormEvent) => { event.preventDefault(); const password = getValue('password'); const confirmPassword = getValue('confirmPassword'); if (password !== confirmPassword) { toast.error(t('err.confirmPasswordDifferents')); console.error('Passwords do not match'); return; } register( getValue('username'), getValue('firstname'), getValue('lastname'), password, ) .then(result => { if (!result) { toast.error(t('err.createUser')); } }) .catch(console.error); }, [register], ); return (
Logo

{t('registerFirstUser')}

); };