import { useTranslate } from '@/hooks/common-hooks'; import { IModalProps } from '@/interfaces/common'; import { InboxOutlined } from '@ant-design/icons'; import { Flex, Modal, Segmented, Tabs, TabsProps, Upload, UploadFile, UploadProps, } from 'antd'; import { Dispatch, SetStateAction, useState } from 'react'; import styles from './index.less'; const { Dragger } = Upload; const FileUpload = ({ directory, fileList, setFileList, }: { directory: boolean; fileList: UploadFile[]; setFileList: Dispatch>; }) => { const { t } = useTranslate('fileManager'); const props: UploadProps = { multiple: true, onRemove: (file) => { const index = fileList.indexOf(file); const newFileList = fileList.slice(); newFileList.splice(index, 1); setFileList(newFileList); }, beforeUpload: (file) => { setFileList((pre) => { return [...pre, file]; }); return false; }, directory, fileList, }; return (

{t('uploadTitle')}

{t('uploadDescription')}

{false &&

{t('uploadLimit')}

}
); }; const FileUploadModal = ({ visible, hideModal, loading, onOk: onFileUploadOk, }: IModalProps) => { const { t } = useTranslate('fileManager'); const [value, setValue] = useState('local'); const [fileList, setFileList] = useState([]); const [directoryFileList, setDirectoryFileList] = useState([]); const clearFileList = () => { setFileList([]); setDirectoryFileList([]); }; const onOk = async () => { const ret = await onFileUploadOk?.([...fileList, ...directoryFileList]); return ret; }; const afterClose = () => { clearFileList(); }; const items: TabsProps['items'] = [ { key: '1', label: t('file'), children: ( ), }, { key: '2', label: t('directory'), children: ( ), }, ]; return ( <> {value === 'local' ? ( ) : ( t('comingSoon', { keyPrefix: 'common' }) )} ); }; export default FileUploadModal;