import React from 'react'; import { useDropzone } from 'react-dropzone'; import { Iconify } from '@seliseblocks/next-images'; import Box from '@mui/material/Box'; import { alpha } from '@mui/material/styles'; import { IUploadProps } from '../types'; /** * @description {UploadBox} - Function for handling file uploads. * @param {boolean} disabled - Indicates whether the upload is disabled. * @param {boolean} error - Indicates whether there is an error. * @param {SxProps} sx - The style for the upload. * @return {JSX.Element} The rendered upload component. */ export const UploadBox = ({ placeholder, error, disabled, sx, ...other }: IUploadProps) => { const { getRootProps, getInputProps, isDragActive, isDragReject } = useDropzone({ disabled, ...other, }); const hasError = isDragReject || error; return ( alpha(theme.palette.grey[500], 0.08), border: (theme) => `dashed 1px ${alpha(theme.palette.grey[500], 0.16)}`, ...(isDragActive && { opacity: 0.72, }), ...(disabled && { opacity: 0.48, pointerEvents: 'none', }), ...(hasError && { color: 'error.main', borderColor: 'error.main', bgcolor: (theme) => alpha(theme.palette.error.main, 0.08), }), '&:hover': { opacity: 0.72, }, ...sx, }} > {placeholder || } ); };