import React, { useCallback } from 'react' import { useDropzone } from 'react-dropzone' import styles from './Dropzone.module.css' import { formatBytes } from '../../utils' export default function Dropzone({ handleOnDrop, disabled, multiple, error }: { handleOnDrop(files: File[]): void disabled?: boolean multiple?: boolean error?: string }) { const onDrop = useCallback(acceptedFiles => handleOnDrop(acceptedFiles), [ handleOnDrop ]) const { getRootProps, getInputProps, isDragActive, isDragReject, acceptedFiles } = useDropzone({ onDrop }) const files = acceptedFiles.map((file: any) => (
  • {file.path} - {formatBytes(file.size, 0)}
  • )) return (
    {acceptedFiles.length > 0 ? ( ) : ( <> {isDragActive && !isDragReject ? ( `Drop it like it's hot!` ) : multiple ? ( `Drag 'n' drop some files here, or click to select files` ) : error ? (
    {error}
    ) : ( `Drag 'n' drop a file here, or click to select a file` )} )}
    ) }