'use client'; import { requestPasswordUpdate } from '@/utils/auth-helpers/server'; import { handleRequest } from '@/utils/auth-helpers/client'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; import { Box, Button, Flex, FormLabel, Input, useColorModeValue, Link } from '@chakra-ui/react'; // Define prop type with allowEmail boolean interface ForgotPasswordProps { allowEmail: boolean; redirectMethod: string; disableButton?: boolean; } export default function ForgotPassword({ allowEmail, redirectMethod }: ForgotPasswordProps) { const router = redirectMethod === 'client' ? useRouter() : null; const textColor = useColorModeValue('navy.700', 'white'); const [isSubmitting, setIsSubmitting] = useState(false); const handleSubmit = async (e: React.FormEvent) => { setIsSubmitting(true); // Disable the button while the request is being handled await handleRequest(e, requestPasswordUpdate, router); setIsSubmitting(false); }; return (
handleSubmit(e)}> Email
Sign in with email and password {allowEmail && ( Sign in via magic link )} Don't have an account? Sign up
); }