'use client' import { infer as zInfer } from 'zod' import { useState, useTransition } from 'react' import { useForm } from 'react-hook-form' import { zodResolver } from '@hookform/resolvers/zod' import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage, } from '@/components/ui/form' import { Input } from '@/components/ui/input' import { CardWrapper } from '@/components/auth/card-wrapper' import { useI18n } from '@/locales/client' import { Button } from '@/components/ui/button' import FormError from '@/components/form-error' import FormSuccess from '@/components/form-success' import { NewPasswordSchema } from '@/schemas' import { AUTH_LOGIN_URL } from '@/config/routes' import { newPassword } from '@/actions/new-password' export const NewPasswordForm = ({ token }: { token: string }) => { const t = useI18n() const [error, setError] = useState('') const [success, setSuccess] = useState('') const [isPending, startTransition] = useTransition() const form = useForm>({ resolver: zodResolver(NewPasswordSchema), defaultValues: { password: '', }, }) const onSubmit = (values: zInfer) => { setError('') setSuccess('') startTransition(() => { newPassword(values, token).then((data) => { // @ts-ignore setError(t(data?.error)) // @ts-ignore setSuccess(t(data?.success)) }) }) } return (
( {t('form.label.password')} )}/>
) }