Skip to content

Commit

Permalink
add fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 27, 2024
1 parent 71b0fcb commit 01bef57
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const BulkEditPreviewModalList = ({
const { bulkDetails } = useBulkOperationDetails({ id: bulkOperationId, interval });

const visibleColumnKeys = getVisibleColumnsKeys(visibleColumns);
const enabled = isPreviewEnabled && bulkDetails?.status === JOB_STATUSES.REVIEW_CHANGES;

const {
contentData,
Expand All @@ -65,7 +66,7 @@ export const BulkEditPreviewModalList = ({
step: EDITING_STEPS.EDIT,
capabilities: currentRecordType,
queryOptions: {
enabled: bulkDetails?.status === JOB_STATUSES.REVIEW_CHANGES,
enabled,
onSuccess: showErrorMessage,
onError: (error) => {
showErrorMessage(error);
Expand Down
4 changes: 4 additions & 0 deletions src/hooks/api/useBulkOperationDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const useBulkOperationDetails = ({

useEffect(() => {
setRefetchInterval(interval);

return () => {
clearInterval();
};
}, [interval]);

const { data, isLoading } = useQuery({
Expand Down
7 changes: 2 additions & 5 deletions src/hooks/useConfirmChanges.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { useState } from 'react';
import { useQueryClient } from 'react-query';

import { useNamespace } from '@folio/stripes/core';

import {
PREVIEW_MODAL_KEY,
BULK_OPERATION_DETAILS_KEY,
Expand All @@ -29,7 +27,6 @@ export const useConfirmChanges = ({
const queryClient = useQueryClient();
const searchParams = useSearchParams();
const { showErrorMessage } = useErrorMessages();
const [namespaceKey] = useNamespace({ key: BULK_OPERATION_DETAILS_KEY });

const [isPreviewModalOpened, setIsPreviewModalOpened] = useState(false);
const [isPreviewLoading, setIsPreviewLoading] = useState(false);
Expand All @@ -50,8 +47,8 @@ export const useConfirmChanges = ({
const confirmChanges = (payload) => {
// as backend reset a status to 'DATA_MODIFICATION' only after the job started
// we need to set it manually to show the preview modal without a delay
queryClient.setQueryData(
[BULK_OPERATION_DETAILS_KEY, namespaceKey, bulkOperationId],
queryClient.setQueriesData(
BULK_OPERATION_DETAILS_KEY,
(preBulkOperation) => ({ ...preBulkOperation, status: JOB_STATUSES.DATA_MODIFICATION }),
);

Expand Down

0 comments on commit 01bef57

Please sign in to comment.