Taichi Masuyama 3 лет назад
Родитель
Сommit
6cbc6eefdb
1 измененных файлов с 14 добавлено и 5 удалено
  1. 14 5
      packages/app/src/components/Admin/G2GDataTransfer.tsx

+ 14 - 5
packages/app/src/components/Admin/G2GDataTransfer.tsx

@@ -4,8 +4,10 @@ import { useTranslation } from 'react-i18next';
 import * as toastr from 'toastr';
 import * as toastr from 'toastr';
 
 
 import { useGenerateTransferKeyWithThrottle } from '~/client/services/g2g-transfer';
 import { useGenerateTransferKeyWithThrottle } from '~/client/services/g2g-transfer';
+import { toastError } from '~/client/util/apiNotification';
 import { apiv3Get } from '~/client/util/apiv3-client';
 import { apiv3Get } from '~/client/util/apiv3-client';
 import { useAdminSocket } from '~/stores/socket-io';
 import { useAdminSocket } from '~/stores/socket-io';
+import customAxios from '~/utils/axios';
 
 
 
 
 import CustomCopyToClipBoard from '../Common/CustomCopyToClipBoard';
 import CustomCopyToClipBoard from '../Common/CustomCopyToClipBoard';
@@ -90,13 +92,20 @@ const G2GDataTransfer = (): JSX.Element => {
     generateTransferKeyWithThrottle();
     generateTransferKeyWithThrottle();
   }, [generateTransferKeyWithThrottle]);
   }, [generateTransferKeyWithThrottle]);
 
 
-  const startTransfer = (e) => {
+  const startTransfer = useCallback(async(e) => {
     e.preventDefault();
     e.preventDefault();
 
 
-    // console.log(startTransferKey);
-    // console.log(selectedCollections);
-    // console.log(optionsMap);
-  };
+    try {
+      await customAxios.post('/_api/v3/g2g-transfer/transfer', {
+        transferKey: startTransferKey,
+        collections,
+        optionsMap,
+      });
+    }
+    catch (errs) {
+      toastError('Failed to transfer');
+    }
+  }, [startTransferKey, collections, optionsMap]);
 
 
   useEffect(() => {
   useEffect(() => {
     setCollectionsAndSelectedCollections();
     setCollectionsAndSelectedCollections();