Files
pi-ku/frontend/src/components/ui/FormField.tsx
T
me ac2f541ebe
CI / Frontend CI (push) Successful in 1m10s
CI / Backend CI (push) Successful in 1m9s
CI / E2E Tests (push) Has been skipped
CI / Generate Certificates (push) Successful in 36s
refactor/optimize e2e test (#3)
how fast i'll go 🏄‍♂️

---------

Co-authored-by: me <ramvignesh-b@github.com>
Reviewed-on: #3
2026-05-06 18:04:11 +00:00

45 lines
1015 B
TypeScript

import type { UseFormRegisterReturn } from "react-hook-form";
interface FormFieldProps {
label: string;
type?: string;
placeholder?: string;
registration: UseFormRegisterReturn;
error?: string;
handleFocus?: () => void;
"data-testid"?: string;
}
export default function FormField({
label,
type = "text",
placeholder,
registration,
error,
handleFocus,
"data-testid": testId,
}: FormFieldProps) {
return (
<div className="form-control">
<label
htmlFor={registration.name}
className="field-label font-display text-base-content/90 font-medium"
>
{label}
</label>
<input
{...registration}
id={registration.name}
data-testid={testId}
type={type}
placeholder={placeholder}
className={`input input-bordered focus:input-primary ${
error ? "input-error" : ""
}`}
onFocus={handleFocus}
/>
{error && <p className="text-error">{error}</p>}
</div>
);
}