import { UploadOutlined } from '@ant-design/icons'; import { Button, Modal, Upload, UploadFile, UploadProps } from 'antd'; import React, { useState } from 'react'; const ImportModal: React.FC<{ visible: boolean; close: () => void; doImpt: (file: any) => Promise; accept: string; }> = ({ visible, close, doImpt, accept }) => { const [fileList, setFileList] = useState([]); const [uploading, setUploading] = useState(false); const handleUpload = async () => { const file = fileList[0]; if (!file || uploading) { return; } setUploading(true); try { await doImpt(file); close(); } catch (e) { console.log(e) } finally { setUploading(false); } }; if (!visible) { return null; } return ( close()} > { setFileList([file]); return false; }} onRemove={() => { setFileList([]); }} accept={accept} maxCount={1} onChange={(info) => { console.log(info); }} > ) } export default ImportModal