|
|
@@ -6,7 +6,6 @@ import { Modal, ModalHeader, ModalBody } from 'reactstrap';
|
|
|
import { apiv3Post } from '~/client/util/apiv3-client';
|
|
|
import { toastError, toastSuccess } from '~/client/util/toastr';
|
|
|
import { usePageBulkExportSelectModal } from '~/features/page-bulk-export/client/stores/modal';
|
|
|
-import type { IPageBulkExportJob } from '~/features/page-bulk-export/interfaces/page-bulk-export';
|
|
|
import { PageBulkExportFormat } from '~/features/page-bulk-export/interfaces/page-bulk-export';
|
|
|
import { useCurrentPagePath } from '~/stores/page';
|
|
|
|
|
|
@@ -17,18 +16,21 @@ const PageBulkExportSelectModal = (): JSX.Element => {
|
|
|
|
|
|
const [isRestartModalOpened, setIsRestartModalOpened] = useState(false);
|
|
|
const [formatMemoForRestart, setFormatMemoForRestart] = useState<PageBulkExportFormat | undefined>(undefined);
|
|
|
- const [duplicateJob, setDuplicateJob] = useState<IPageBulkExportJob | undefined>(undefined);
|
|
|
+ const [duplicateJobInfo, setDuplicateJobInfo] = useState<{createdAt: string} | undefined>(undefined);
|
|
|
|
|
|
const startBulkExport = async(format: PageBulkExportFormat) => {
|
|
|
try {
|
|
|
setFormatMemoForRestart(format);
|
|
|
await apiv3Post('/page-bulk-export', { path: currentPagePath, format });
|
|
|
toastSuccess(t('page_export.bulk_export_started'));
|
|
|
+
|
|
|
+ // setDuplicateJob({ createdAt: new Date(), format } as any);
|
|
|
+ // setIsRestartModalOpened(true);
|
|
|
}
|
|
|
catch (e) {
|
|
|
const errorCode = e?.[0].code ?? 'page_export.failed_to_export';
|
|
|
if (errorCode === 'page_export.duplicate_bulk_export_job_error') {
|
|
|
- setDuplicateJob(e[0].args.duplicateJob);
|
|
|
+ setDuplicateJobInfo(e[0].args.duplicateJob);
|
|
|
setIsRestartModalOpened(true);
|
|
|
}
|
|
|
else {
|
|
|
@@ -51,6 +53,16 @@ const PageBulkExportSelectModal = (): JSX.Element => {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
+ const formatStartDate = (createdAt: string) => {
|
|
|
+ const date = new Date(createdAt);
|
|
|
+ const mm = String(date.getMonth() + 1).padStart(2, '0');
|
|
|
+ const dd = String(date.getDate()).padStart(2, '0');
|
|
|
+ const hh = String(date.getHours()).padStart(2, '0');
|
|
|
+ const min = String(date.getMinutes()).padStart(2, '0');
|
|
|
+
|
|
|
+ return `${mm}/${dd} ${hh}:${min}`;
|
|
|
+ };
|
|
|
+
|
|
|
return (
|
|
|
<>
|
|
|
{status != null && (
|
|
|
@@ -82,11 +94,21 @@ const PageBulkExportSelectModal = (): JSX.Element => {
|
|
|
</ModalHeader>
|
|
|
<ModalBody>
|
|
|
{t('page_export.export_in_progress_explanation')}
|
|
|
- <div className="my-1 text-danger">
|
|
|
- <small className="text-danger">
|
|
|
- {t('page_export.export_cancel_warning')}
|
|
|
- </small>
|
|
|
+ <div className="text-danger">
|
|
|
+ {t('page_export.export_cancel_warning')}:
|
|
|
</div>
|
|
|
+ { duplicateJobInfo && (
|
|
|
+ <div className="my-1">
|
|
|
+ <ul>
|
|
|
+ { formatMemoForRestart && (
|
|
|
+ <li>
|
|
|
+ {t('page_export.format')}: {formatMemoForRestart === PageBulkExportFormat.md ? t('page_export.markdown') : 'PDF'}
|
|
|
+ </li>
|
|
|
+ )}
|
|
|
+ <li>{t('page_export.started_on')}: {formatStartDate(duplicateJobInfo.createdAt)}</li>
|
|
|
+ </ul>
|
|
|
+ </div>
|
|
|
+ )}
|
|
|
<div className="d-flex justify-content-center mt-3">
|
|
|
<button className="btn btn-primary" type="button" onClick={() => restartBulkExport()}>
|
|
|
{t('page_export.restart')}
|