Create a registration form #135

Merged
bustikiller merged 4 commits from registration-form into main 2024-12-07 18:13:04 +00:00
Showing only changes of commit 054e1c6da0 - Show all commits

View File

@ -11,6 +11,7 @@ import { register } from '@/app/api/authentication';
import { getCaptchaChallenge } from '@/app/api/captcha'; import { getCaptchaChallenge } from '@/app/api/captcha';
export default function RegistrationForm() { export default function RegistrationForm() {
const [submitted, setSubmitted] = useState<boolean>(false);
const [errors, setErrors] = useState<string[]>([]); const [errors, setErrors] = useState<string[]>([]);
const [email, setEmail] = useState<string>(""); const [email, setEmail] = useState<string>("");
@ -36,6 +37,12 @@ export default function RegistrationForm() {
useEffect(refreshCaptcha, []) useEffect(refreshCaptcha, [])
return ( return (
submitted ? (
<div className="card flex justify-evenly py-5 flex-col">
<div className="text-green-500">Registration successful. Check your email for a confirmation link.</div>
</div>
) : (
<div className="card flex justify-evenly py-5 flex-col"> <div className="card flex justify-evenly py-5 flex-col">
<FloatLabel className="my-4"> <FloatLabel className="my-4">
<InputText id="email" type="email" className='rounded-sm' onChange={(e) => setEmail(e.target.value)} /> <InputText id="email" type="email" className='rounded-sm' onChange={(e) => setEmail(e.target.value)} />
@ -77,7 +84,7 @@ export default function RegistrationForm() {
id: captchaId, id: captchaId,
answer: captchaAnswer answer: captchaAnswer
}, },
onRegister: () => { setErrors([]) }, onRegister: () => { setErrors([]); setSubmitted(true) },
onError: (errors) => { refreshCaptcha(); setErrors(errors) } onError: (errors) => { refreshCaptcha(); setErrors(errors) }
} }
)} )}
@ -85,5 +92,7 @@ export default function RegistrationForm() {
Register Register
</button> </button>
</div> </div>
)
); );
} }