diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js index 45fca6a1..8c3f1cdf 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModal.js @@ -81,10 +81,12 @@ export const BulkEditPreviewModal = ({ dismissible onClose={onKeepEditing} > - + {open && ( + + )} ); }; diff --git a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js index aab38695..44c383cf 100644 --- a/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js +++ b/src/components/BulkEditPane/BulkEditListResult/BulkEditInAppPreviewModal/BulkEditPreviewModalList.js @@ -3,6 +3,7 @@ import PropTypes from 'prop-types'; import { FormattedMessage, } from 'react-intl'; +import { useQueryClient } from 'react-query'; import { MessageBanner, @@ -13,7 +14,6 @@ import { } from '@folio/stripes-acq-components'; import { Preloader } from '@folio/stripes-data-transfer-components'; -import { useQueryClient } from 'react-query'; import { PREVIEW_COLUMN_WIDTHS } from '../../../PermissionsModal/constants/lists'; import css from './BulkEditInAppPreviewModal.css'; import { usePagination } from '../../../../hooks/usePagination'; @@ -50,8 +50,12 @@ export const BulkEditPreviewModalList = ({ } = usePagination(PAGINATION_CONFIG); const [previewLoaded, setPreviewLoaded] = useState(false); - const interval = previewLoaded ? 0 : 1; - const { bulkDetails } = useBulkOperationDetails({ id: bulkOperationId, interval, cacheTime: 0, staleTime: 0 }); + const interval = previewLoaded ? 0 : 1000; + const { bulkDetails } = useBulkOperationDetails({ + id: bulkOperationId, + interval, + enabled: isPreviewEnabled, + }); const visibleColumnKeys = getVisibleColumnsKeys(visibleColumns); const enabled = isPreviewEnabled && bulkDetails?.status === JOB_STATUSES.REVIEW_CHANGES; diff --git a/src/hooks/useConfirmChanges.js b/src/hooks/useConfirmChanges.js index 32558977..4d179042 100644 --- a/src/hooks/useConfirmChanges.js +++ b/src/hooks/useConfirmChanges.js @@ -36,29 +36,22 @@ export const useConfirmChanges = ({ const totalRecords = bulkDetails?.totalNumOfRecords; - const resetStatusToDataModification = () => { - queryClient.setQueriesData( - BULK_OPERATION_DETAILS_KEY, - (preBulkOperation) => ({ ...preBulkOperation, status: JOB_STATUSES.DATA_MODIFICATION }), - ); - }; - const openPreviewModal = () => { setIsPreviewModalOpened(true); }; const closePreviewModal = () => { setIsPreviewModalOpened(false); - resetStatusToDataModification(); }; const confirmChanges = (payload) => { - resetStatusToDataModification(); + setIsPreviewLoading(true); queryClient.removeQueries(PREVIEW_MODAL_KEY); - - setIsPreviewModalOpened(true); - setIsPreviewLoading(true); + queryClient.setQueriesData( + BULK_OPERATION_DETAILS_KEY, + (preBulkOperation) => ({ ...preBulkOperation, status: JOB_STATUSES.DATA_MODIFICATION }), + ); updateFn(payload) .then(() => bulkOperationStart({ @@ -68,6 +61,7 @@ export const useConfirmChanges = ({ })) .then((response) => { showErrorMessage(response); + openPreviewModal(); }) .catch((error) => { showErrorMessage(error);