// /app/login/page.tsx 'use test' // Marks this component as a client component 'use client' import classnames from 'classnames'; import { useEffect, useState } from 'react' import { Schibsted_Grotesk } from 'next/font/google' const font = Schibsted_Grotesk({ subsets: ['latin'] }) export default function ForgotPasswordPage() { const [email, setEmail] = useState(''); const [message, setMessage] = useState(''); const [apiUrl, setapiUrl] = useState(""); useEffect(() => { fetch("/api/backendApiUrl") .then((res) => res.json()) .then((data) => { setapiUrl(data.apiUrl) }); }, []); const handleSubmit = async (e: React.SubmitEvent) => { e.preventDefault(); const res = await fetch(`http://${apiUrl}/forgot_password`, { method: 'POST', headers: { 'Content-Type': 'application/json' , }, body: JSON.stringify({ user: { email } }), }); const data = await res.json(); if (res.ok || data.errors[0] == 'Email not found') { setMessage('If there is an account with this address, a reset link will be sent to your email shortly.'); } else { setMessage(data.errors?.join(', ') || 'An error occurred.'); } }; return (
Britton Benefits
Forgot Password
setEmail(e.target.value)} className="appearance-none relative block w-full px-3 py-2 bg-platinum border border-gray-300 placeholder-bluetang text-deepcove rounded-md focus:outline-none focus:ring-indigo-500 focus:border-indigo-500 focus:z-10 sm:text-sm" required />
{message &&

{message}

}
) }