import { typeboxResolver } from "@hookform/resolvers/typebox"; import { Type } from "core/utils"; import type { ComponentPropsWithoutRef } from "react"; import { useForm } from "react-hook-form"; import { twMerge } from "tailwind-merge"; import { Button } from "ui"; import * as Formy from "ui/components/form/Formy"; export type LoginFormProps = Omit, "onSubmit"> & { className?: string; formData?: any; }; const schema = Type.Object({ email: Type.String({ pattern: "^[\\w-\\.]+@([\\w-]+\\.)+[\\w-]{2,4}$" }), password: Type.String({ minLength: 8 // @todo: this should be configurable }) }); export function LoginForm({ formData, className, method = "POST", ...props }: LoginFormProps) { const { register, formState: { isValid, errors } } = useForm({ mode: "onChange", defaultValues: formData, resolver: typeboxResolver(schema) }); return (
Email address Password
); }