import React from "react"; import { useForm } from "react-hook-form"; // ui import { Input, PrimaryButton } from "components/ui"; // types type EmailPasswordFormValues = { email: string; password?: string; medium?: string; }; type Props = { onSubmit: (formData: EmailPasswordFormValues) => Promise; setIsResettingPassword: (value: boolean) => void; }; export const EmailPasswordForm: React.FC = (props) => { const { onSubmit, setIsResettingPassword } = props; // form info const { register, handleSubmit, formState: { errors, isSubmitting, isValid, isDirty }, } = useForm({ defaultValues: { email: "", password: "", medium: "email", }, mode: "onChange", reValidateMode: "onChange", }); return ( <>
/^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test( value ) || "Email address is not valid", }} error={errors.email} placeholder="Enter your email address..." className="border-custom-border-300 h-[46px]" />
{isSubmitting ? "Signing in..." : "Sign in"}
); };