/* Copyright (C) 2024 Manuel Bustillo*/ 'use client'; import { FloatLabel } from 'primereact/floatlabel'; import { InputText } from 'primereact/inputtext'; import { useState, useEffect } from 'react'; import { classNames } from './button'; import { getSlug } from '@/app/lib/utils'; import { register } from '@/app/api/authentication'; import { getCaptchaChallenge } from '@/app/api/captcha'; export default function RegistrationForm() { const [submitted, setSubmitted] = useState(false); const [errors, setErrors] = useState([]); const [email, setEmail] = useState(""); const [password, setPassword] = useState(""); const [passwordConfirmation, setPasswordConfirmation] = useState(""); const [slug, setSlug] = useState(getSlug()); const [captchaId, setCaptchaId] = useState(""); const [captchaUrl, setCaptchaUrl] = useState(""); const [captchaAnswer, setCaptchaAnswer] = useState(""); const refreshCaptcha = () => { getCaptchaChallenge({ onRetrieve: (id, url) => { console.log(id, url); setCaptchaId(id); setCaptchaUrl(url); setCaptchaAnswer(""); } }); } useEffect(refreshCaptcha, []) return ( submitted ? (
Registration successful. Check your email for a confirmation link.
) : (
setEmail(e.target.value)} /> setPassword(e.target.value)} /> setPasswordConfirmation(e.target.value)} /> setSlug(e.target.value)} /> captcha setCaptchaAnswer(e.target.value)} /> {errors.map((error, index) => (
{error}
))}
) ); }