import { ExclamationCircleFilled, LoadingOutlined } from '@ant-design/icons'; import { css } from '@nocobase/client'; import { Button, Modal, Space, Spin } from 'antd'; import { saveAs } from 'file-saver'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { NAMESPACE } from './constants'; import { useImportContext } from './context'; export const ImportStatus = { IMPORTING: 1, IMPORTED: 2, }; export const ImportModal = (props: any) => { const { t } = useTranslation(NAMESPACE); const { importModalVisible, importStatus, importResult, setImportModalVisible } = useImportContext(); const { data: fileData, meta } = importResult ?? {}; const doneHandler = () => { setImportModalVisible(false); }; const downloadFailureDataHandler = () => { const arrayBuffer = new Int8Array(fileData?.data); const blob = new Blob([arrayBuffer], { type: 'application/x-xls' }); saveAs(blob, `fail.xlsx`); }; return (
{importStatus === ImportStatus.IMPORTING && ( } tip={t('Excel data importing')} /> )} {importStatus === ImportStatus.IMPORTED && (

{t('Import done, total success have {{successCount}} , total failure have {{failureCount}}', { ...(meta ?? {}), })}

{meta?.failureCount > 0 && ( )}
)}
); };