From b6724ab8c1ce8272090092f47b934e8dcb264501 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期四, 19 九月 2024 10:49:51 +0800
Subject: [PATCH] #

---
 zy-acs-flow/src/page/components/ImportModal.jsx |   31 +++++++++++++++----------------
 1 files changed, 15 insertions(+), 16 deletions(-)

diff --git a/zy-acs-flow/src/page/components/ImportModal.jsx b/zy-acs-flow/src/page/components/ImportModal.jsx
index 309ee86..2344d49 100644
--- a/zy-acs-flow/src/page/components/ImportModal.jsx
+++ b/zy-acs-flow/src/page/components/ImportModal.jsx
@@ -13,19 +13,19 @@
     Form,
     Toolbar,
     useRefresh,
+    useTranslate
 } from 'react-admin';
 import { Link } from 'react-router-dom';
 import DialogCloseButton from './DialogCloseButton';
 import { usePapaParse } from './usePapaParse';
 
-export function ImportModal({ open, onClose, sampleCsv, useCodeImport }) {
+const ImportModal = ({ open, onClose, importTemp, useCodeImport, onceBatch = 10 }) => {
     const refresh = useRefresh();
-
-    const SAMPLE_URL = `data:text/csv;name=crm_contacts_sample.csv;charset=utf-8,${encodeURIComponent(sampleCsv.default)}`;
+    const translate = useTranslate();
 
     const { processBatch } = useCodeImport();
     const { importer, parseCsv, reset } = usePapaParse({
-        batchSize: 10,
+        batchSize: onceBatch,
         processBatch,
     });
 
@@ -62,7 +62,7 @@
     return (
         <Dialog open={open} maxWidth="md" fullWidth>
             <DialogCloseButton onClose={handleClose} />
-            <DialogTitle>Import</DialogTitle>
+            <DialogTitle>{translate('common.action.import.title')}</DialogTitle>
             <DialogContent>
                 <Form>
                     <Stack spacing={2}>
@@ -90,8 +90,7 @@
                                         },
                                     }}
                                 >
-                                    The import is running, please do not close
-                                    this tab.
+                                    {translate('common.action.import.tips')}
                                 </Alert>
                                 <Typography variant="body2">
                                     Imported{' '}
@@ -117,7 +116,7 @@
                                                 onClick={handleReset}
                                                 color="error"
                                             >
-                                                Stop import
+                                                {translate('common.action.import.stop')}
                                             </MuiLink>
                                         </>
                                     )}
@@ -127,8 +126,7 @@
 
                         {importer.state === 'error' && (
                             <Alert severity="error">
-                                Failed to import this file, please make sure
-                                your provided a valid CSV file.
+                                {translate('common.action.import.err')}
                             </Alert>
                         )}
 
@@ -147,15 +145,14 @@
                                     action={
                                         <Button
                                             component={Link}
-                                            label="Download CSV sample"
+                                            label="common.action.import.download"
                                             color="info"
-                                            to={SAMPLE_URL}
+                                            to={importTemp}
                                             download={'crm_contacts_sample.csv'}
                                         />
                                     }
                                 >
-                                    Here is a sample CSV file you can use as a
-                                    template
+                                    {translate('common.action.import.msg')}
                                 </Alert>
 
                                 <FileInput
@@ -185,7 +182,7 @@
                     {importer.state === 'idle' ? (
                         <>
                             <Button
-                                label="Import"
+                                label="common.action.import.title"
                                 variant="contained"
                                 onClick={startImport}
                                 disabled={!file}
@@ -193,7 +190,7 @@
                         </>
                     ) : (
                         <Button
-                            label="Close"
+                            label="ra.action.close"
                             onClick={handleClose}
                             disabled={importer.state === 'running'}
                         />
@@ -210,3 +207,5 @@
 
     return `${minutes}m ${seconds}s`;
 }
+
+export default ImportModal;
\ No newline at end of file

--
Gitblit v1.9.1