diff --git a/src/Components/Input/TextInput.tsx b/src/Components/Input/TextInput.tsx index 8d669a19..85caa770 100644 --- a/src/Components/Input/TextInput.tsx +++ b/src/Components/Input/TextInput.tsx @@ -15,17 +15,38 @@ type InputTextProps = { } -export function TextInput({labelTitle, labelStyle, type, dataField, containerStyle, inputStyle, defaultValue, placeholder, autocomplete, updateFormValue} : InputTextProps){ +export function TextInput({ labelTitle, labelStyle, type, dataField, containerStyle, inputStyle, defaultValue, placeholder, autocomplete, updateFormValue }: InputTextProps) { + const [inputValue, setInputValue] = useState(defaultValue || ""); - return( + useEffect(() => { + setInputValue(defaultValue || ""); + }, [defaultValue]); + + const handleChange = (e: React.ChangeEvent) => { + const newValue = e.target.value; + setInputValue(newValue); + if (updateFormValue) { + updateFormValue(newValue); + } + }; + + return (
- {labelTitle ? - : " "} - updateFormValue&& updateFormValue(e.target.value)}className={`tw-input tw-input-bordered tw-w-full ${inputStyle ? inputStyle : ""}`} /> + {labelTitle ? ( + + ) : null} +
- ) -} - - + ); +} \ No newline at end of file