import { Button } from '@heroui/button' import { Input } from '@heroui/input' import { useRef, useState } from 'react' export interface FileInputProps { onChange: (file: File) => Promise | void onDelete?: () => Promise | void label?: string accept?: string } const FileInput: React.FC = ({ onChange, onDelete, label, accept }) => { const inputRef = useRef(null) const [isLoading, setIsLoading] = useState(false) return (
{ try { setIsLoading(true) const file = e.target.files?.[0] if (file) { await onChange(file) } } catch (error) { console.error(error) } finally { setIsLoading(false) if (inputRef.current) inputRef.current.value = '' } }} />
) } export default FileInput