'use client'; import { updatePassword } 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, FormLabel, Input, useColorModeValue } from '@chakra-ui/react'; interface UpdatePasswordProps { redirectMethod: string; } export default function UpdatePassword({ redirectMethod }: UpdatePasswordProps) { 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, updatePassword, router); setIsSubmitting(false); }; return (
handleSubmit(e)}> New Password Confirm New Password
); }