"use client"; import { ReactNode } from "react"; import { FieldPath, FieldValues, UseFormRegister, FieldError, } from "react-hook-form"; interface FormFieldProps { id: FieldPath; label: string; registerAction: UseFormRegister; error?: FieldError; required?: boolean; placeholder?: string; type?: "text" | "email" | "password" | "select" | "checkbox" | "number"; options?: { id: string; name: string }[]; className?: string; disabled?: boolean; children?: ReactNode; } export function FormField({ id, label, registerAction, error, required = false, placeholder = "", type = "text", options = [], className = "", disabled = false, children, }: Readonly>) { const inputClassName = "w-full p-2 border rounded-md"; return (
{(() => { if (type === "select") { return ( ); } if (type === "checkbox") { return (
{children}
); } return ( ); })()} {error &&

{error.message}

}
); }