import React from "react"; import Link from "next/link"; import { useForm } from "react-hook-form"; // ui import { Input, PrimaryButton } from "components/ui"; // types type EmailPasswordFormValues = { email: string; password?: string; confirm_password: string; medium?: string; }; type Props = { onSubmit: (formData: EmailPasswordFormValues) => Promise; }; export const EmailSignUpForm: React.FC = (props) => { const { onSubmit } = props; const { register, handleSubmit, watch, formState: { errors, isSubmitting, isValid, isDirty }, } = useForm({ defaultValues: { email: "", password: "", confirm_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]" />
{ if (watch("password") != val) { return "Your passwords do no match"; } }, }} error={errors.confirm_password} placeholder="Confirm your password..." className="border-custom-border-300 h-[46px]" />
Already have an account? Sign in.
{isSubmitting ? "Signing up..." : "Sign up"}
); };