import { useRef, useState } from 'react'; import { UploadIcon } from '../Icons'; import Button from './Button'; import Label from './Label'; interface FileInputProps { id?: string required?: boolean label: string acceptType?: string widthClass?: string onChange?: (event: React.ChangeEvent) => void } function FileInput({ id, required, label, acceptType, widthClass = 'w-full', onChange }: FileInputProps) { const inputRef = useRef(null); const [labelText, setLabelText] = useState(''); const handleUploadClick = () => { inputRef.current?.click(); }; const handleFileChange = (event: React.ChangeEvent) => { if (event.target.files && event.target.files.length > 0) { setLabelText(event.target.files[0].name) } else { setLabelText('') } if (onChange) { onChange(event); } }; return (
); } export default FileInput;