mirror of
https://github.com/ramvignesh-b/pi-ku.git
synced 2026-05-04 15:56:56 +00:00
refactor: modularize form fields into a separate component
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import type { UseFormRegisterReturn } from "react-hook-form";
|
||||
|
||||
interface FormFieldProps {
|
||||
label: string;
|
||||
type?: string;
|
||||
placeholder?: string;
|
||||
registration: UseFormRegisterReturn;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
export default function FormField({
|
||||
label,
|
||||
type = "text",
|
||||
placeholder,
|
||||
registration,
|
||||
error,
|
||||
}: FormFieldProps) {
|
||||
return (
|
||||
<div className="form-control">
|
||||
<label className="field-label font-display text-primary-content">{label}</label>
|
||||
<input
|
||||
{...registration}
|
||||
type={type}
|
||||
placeholder={placeholder}
|
||||
className={`input input-bordered focus:input-primary ${
|
||||
error ? "input-error" : ""
|
||||
}`}
|
||||
/>
|
||||
{error && <p className="field-error">{error}</p>}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user