// @ts-nocheck import { useRef } from 'react'; import { Button, Intent } from '@blueprintjs/core'; import clsx from 'classnames'; import { Box, Icon, Stack } from '@/components'; import { Dropzone, DropzoneProps } from '@/components/Dropzone'; import { MIME_TYPES } from '@/components/Dropzone/mine-types'; import { useUncontrolled } from '@/hooks/useUncontrolled'; import styles from './ImportDropzone.module.css'; export interface ImportDropzoneFieldProps { initialValue?: File; value?: File; onChange?: (file: File) => void; dropzoneProps?: DropzoneProps; uploadIcon?: JSX.Element; title?: string; subtitle?: string; classNames?: Record; } export function ImportDropzoneField({ initialValue, value, onChange, dropzoneProps, uploadIcon = , title = 'Drag images here or click to select files', subtitle = 'Drag and Drop file here or Choose file', classNames, }: ImportDropzoneFieldProps) { const [localValue, handleChange] = useUncontrolled({ value, initialValue, finalValue: null, onChange, }); const openRef = useRef<() => void>(null); const handleRemove = () => { handleChange(null); }; return ( handleChange(files[0])} onReject={(files) => console.log('rejected files', files)} maxSize={5 * 1024 ** 2} accept={[MIME_TYPES.csv, MIME_TYPES.xls, MIME_TYPES.xlsx]} classNames={{ root: classNames?.root, content: styles.dropzoneContent }} activateOnClick={false} openRef={openRef} {...dropzoneProps} > {uploadIcon && {uploadIcon}} {localValue ? (

{localValue.name}

) : ( {title &&

{title}

} {subtitle && {subtitle}}
)}
); }