'use client'; import { createBusterRoute, BusterRoutes } from '@/routes'; import { isValidEmail, timeout } from '@/lib'; import { Button, Input, Result } from 'antd'; import Link from 'next/link'; import React, { useState } from 'react'; import { Title, Text } from '@/components/ui'; import { useMemoizedFn } from 'ahooks'; import { useBusterNotifications } from '@/context/BusterNotifications'; import { useStyles } from '@/app/auth/_LoginComponents/LoginForm'; export const ResetEmailForm: React.FC<{ queryEmail: string; resetPasswordEmailSend: (d: { email: string }) => Promise<{ error: string } | undefined>; }> = ({ queryEmail, resetPasswordEmailSend }) => { const [loading, setLoading] = useState(false); const [email, setEmail] = useState(queryEmail); const { styles, cx } = useStyles(); const [emailSent, setEmailSent] = useState(false); const { openErrorNotification } = useBusterNotifications(); const disabled = !email || !isValidEmail(email); const handleResetPassword = useMemoizedFn(async () => { if (disabled) return; setLoading(true); const [res] = await Promise.all([resetPasswordEmailSend({ email }), timeout(450)]); if (res?.error) { openErrorNotification(res.error); } else { setEmailSent(true); } setLoading(false); }); if (emailSent) { return (