"use client"; import { HTMLInputTypeAttribute, useState } from "react"; import { RegisterOptions, UseFormRegister } from "react-hook-form"; function InputGroup({ id, label, register, type, validation, error, }: { label: string; id: string; register: UseFormRegister; type: HTMLInputTypeAttribute; validation?: RegisterOptions; error?: string; }) { const [isFocused, setIsFocused] = useState(false); const [hasValue, setHasValue] = useState(false); const { onChange, ...rest } = register(id, validation); const handleChange = (e: React.ChangeEvent) => { setHasValue(e.target.value !== ""); onChange(e); }; return ( setIsFocused(true)} onBlur={() => setIsFocused(false)} /> {label} * {error && {error}} ); } export default InputGroup;
{error}