import { useRef, useState } from 'react'; import { UploadIcon } from '../Icons'; import Button from './Button'; import Label from './Label'; interface FileInputProps extends Omit, 'className' | 'title' | 'style' | 'accept' | 'type'> { label: string tooltip?: string acceptType?: string dimensions?: string onChange?: (event: React.ChangeEvent) => void } function FileInput({ label, acceptType, tooltip, dimensions = 'w-fit', onChange, ...props }: FileInputProps) { const inputRef = useRef(null); const [fileName, setFileName] = useState(''); const handleUploadClick = () => { inputRef.current?.click(); }; const handleFileChange = (event: React.ChangeEvent) => { if (event.target.files && event.target.files.length > 0) { setFileName(event.target.files[0].name) } else { setFileName('') } if (onChange) { onChange(event); } }; return (
); } export default FileInput;