import type { FieldErrors, UseFormHandleSubmit, UseFormRegister, UseFormWatch, } from "react-hook-form"; import { Box } from "@mui/material"; import { Button } from "@/components/ui/button"; import { FormErrorMessage } from "@/components/ui/form-error-message"; import { FormField } from "@/components/ui/form-field"; import { PasswordField } from "@/components/ui/password-field"; import { TextField } from "@/components/ui/text-field"; import { loginSchema, type LoginFormValues } from "@/domain/auth/schemas/login-schema"; export type LoginFormProps = { register: UseFormRegister; handleSubmit: UseFormHandleSubmit; watch: UseFormWatch; errors: FieldErrors; onSubmit: (values: LoginFormValues) => void; isLoggingIn: boolean; loginError: Error | null; }; export function LoginForm({ register, handleSubmit, watch, errors, onSubmit, isLoggingIn, loginError, }: LoginFormProps) { const [username, password] = watch(["username", "password"]); const isSubmitDisabled = !loginSchema.safeParse({ username, password }).success; return ( {Boolean(loginError) && ( )} ); }