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