import { useState, type FormEvent } from 'react' import toast from 'react-hot-toast' import * as m from 'paraglide/messages.js' import { resetPassword } from 'utils/auth-client' import Button from 'components/Button' import Modal from 'components/Modal' export default function ForgorForm(props: { token: string }) { const { token } = props const [loading, setLoading] = useState(false) async function handleSubmit(ev: FormEvent) { ev.preventDefault() const formData = new FormData(ev.currentTarget) const password = formData.get('password') if (!password) return setLoading(true) const { data, error } = await resetPassword({ newPassword: password as string, token }) setLoading(false) if (error) { console.error(error) toast.error(error.message || 'Unknown Error') return } toast.success(m.passwordResetSuccesful()) window.location.replace('/') } return (
) }