|
@@ -1,12 +1,10 @@
|
|
|
-import React, {
|
|
|
|
|
- useCallback, useEffect, useState, useMemo,
|
|
|
|
|
-} from 'react';
|
|
|
|
|
|
|
+import React, { useCallback, useEffect, useState } from 'react';
|
|
|
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
import { useTranslation } from 'react-i18next';
|
|
|
-import { debounce } from 'throttle-debounce';
|
|
|
|
|
import * as toastr from 'toastr';
|
|
import * as toastr from 'toastr';
|
|
|
|
|
|
|
|
-import { apiv3Get, apiv3Post } from '~/client/util/apiv3-client';
|
|
|
|
|
|
|
+import { useGenerateTransferKeyWithThrottle } from '~/client/services/g2g-transfer';
|
|
|
|
|
+import { apiv3Get } from '~/client/util/apiv3-client';
|
|
|
import { useAdminSocket } from '~/stores/socket-io';
|
|
import { useAdminSocket } from '~/stores/socket-io';
|
|
|
|
|
|
|
|
import CustomCopyToClipBoard from '../Common/CustomCopyToClipBoard';
|
|
import CustomCopyToClipBoard from '../Common/CustomCopyToClipBoard';
|
|
@@ -26,7 +24,6 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
const [isExporting, setExporting] = useState(false);
|
|
const [isExporting, setExporting] = useState(false);
|
|
|
// TODO: データのエクスポートが完了したことが分かるようにする
|
|
// TODO: データのエクスポートが完了したことが分かるようにする
|
|
|
const [isExported, setExported] = useState(false);
|
|
const [isExported, setExported] = useState(false);
|
|
|
- const [transferKey, setTransferKey] = useState('');
|
|
|
|
|
|
|
|
|
|
const fetchData = useCallback(async() => {
|
|
const fetchData = useCallback(async() => {
|
|
|
const [{ data: collectionsData }, { data: statusData }] = await Promise.all([
|
|
const [{ data: collectionsData }, { data: statusData }] = await Promise.all([
|
|
@@ -70,11 +67,11 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
}
|
|
}
|
|
|
}, [socket]);
|
|
}, [socket]);
|
|
|
|
|
|
|
|
- const generateTransferKeyWithDebounce = useMemo(() => debounce(1000, async() => {
|
|
|
|
|
- const response = await apiv3Post('/g2g-transfer/generate-key');
|
|
|
|
|
- const { transferKey } = response.data;
|
|
|
|
|
- setTransferKey(transferKey);
|
|
|
|
|
- }), []);
|
|
|
|
|
|
|
+ const { transferKey, generateTransferKeyWithThrottle } = useGenerateTransferKeyWithThrottle();
|
|
|
|
|
+
|
|
|
|
|
+ const onClickHandler = useCallback(() => {
|
|
|
|
|
+ generateTransferKeyWithThrottle();
|
|
|
|
|
+ }, [generateTransferKeyWithThrottle]);
|
|
|
|
|
|
|
|
const transferData = () => {
|
|
const transferData = () => {
|
|
|
// データ移行の処理
|
|
// データ移行の処理
|
|
@@ -111,7 +108,7 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
|
|
|
|
|
<div className="form-group row mt-4">
|
|
<div className="form-group row mt-4">
|
|
|
<div className="col-md-3">
|
|
<div className="col-md-3">
|
|
|
- <button type="button" className="btn btn-primary w-100" onClick={generateTransferKeyWithDebounce}>
|
|
|
|
|
|
|
+ <button type="button" className="btn btn-primary w-100" onClick={onClickHandler}>
|
|
|
{t('g2g_data_transfer.publish_transfer_key')}
|
|
{t('g2g_data_transfer.publish_transfer_key')}
|
|
|
</button>
|
|
</button>
|
|
|
</div>
|
|
</div>
|
|
@@ -134,6 +131,7 @@ const G2GDataTransfer = (): JSX.Element => {
|
|
|
onExportingRequested={exportingRequestedHandler}
|
|
onExportingRequested={exportingRequestedHandler}
|
|
|
onClose={() => setExportModalOpen(false)}
|
|
onClose={() => setExportModalOpen(false)}
|
|
|
collections={collections}
|
|
collections={collections}
|
|
|
|
|
+ allChecked={true}
|
|
|
/>
|
|
/>
|
|
|
</div>
|
|
</div>
|
|
|
);
|
|
);
|