'use client'; import React from 'react'; import { signUp } from '@/utils/auth-helpers/server'; import { handleRequest } from '@/utils/auth-helpers/client'; import { useRouter } from 'next/navigation'; import { useState } from 'react'; import { Flex, useColorModeValue, Link, FormLabel, Box, Input, Button } from '@chakra-ui/react'; // Define prop type with allowEmail boolean interface SignUpProps { allowEmail: boolean; redirectMethod: string; } export default function SignUp({ allowEmail, redirectMethod }: SignUpProps) { 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, signUp, router); setIsSubmitting(false); }; return (
handleSubmit(e)}> Email Password
Forgot your password? Already have an account? {allowEmail && ( Sign in via magic link )}
); }