'use client'; import { useForm, SubmitHandler, FormProvider } from 'react-hook-form'; import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; import Link from 'next/link'; import { Button } from '@gitroom/react/form/button'; import { Input } from '@gitroom/react/form/input'; import { useMemo, useState } from 'react'; import { classValidatorResolver } from '@hookform/resolvers/class-validator'; import { ForgotPasswordDto } from '@gitroom/nestjs-libraries/dtos/auth/forgot.password.dto'; import { useT } from '@gitroom/react/translation/get.transation.service.client'; type Inputs = { email: string; }; export function Forgot() { const t = useT(); const [loading, setLoading] = useState(false); const [state, setState] = useState(false); const resolver = useMemo(() => { return classValidatorResolver(ForgotPasswordDto); }, []); const form = useForm({ resolver, }); const fetchData = useFetch(); const onSubmit: SubmitHandler = async (data) => { setLoading(true); await fetchData('/auth/forgot', { method: 'POST', body: JSON.stringify({ ...data, provider: 'LOCAL', }), }); setState(true); setLoading(false); }; return (

{t('forgot_password_1', 'Forgot Password')}

{!state ? ( <>

{t('go_back_to_login', 'Go back to login')}

) : ( <>
{t( 'we_have_send_you_an_email_with_a_link_to_reset_your_password', 'We have send you an email with a link to reset your password.' )}

{t('go_back_to_login', 'Go back to login')}

)}
); }