Skip to content

Commit

Permalink
UIBULKED-553 Prevent duplication of errors for bulk operation start
Browse files Browse the repository at this point in the history
  • Loading branch information
vashjs committed Oct 29, 2024
1 parent dbb402d commit 8ee9722
Show file tree
Hide file tree
Showing 5 changed files with 6 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const BulkEditPreviewModal = ({
id: bulkDetails?.id,
approach: APPROACHES.IN_APP,
step: EDITING_STEPS.COMMIT,
});
}).then(showErrorMessage);

onChangesCommited();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { useBulkOperationDelete } from '../../../../hooks/api/useBulkOperationDelete';
import { ListFileUploader } from '../../../shared/ListFileUploader';
import { useSearchParams } from '../../../../hooks/useSearchParams';
import { useErrorMessages } from '../../../../hooks/useErrorMessages';

const BulkEditManualUploadModal = ({
operationId,
Expand All @@ -38,6 +39,7 @@ const BulkEditManualUploadModal = ({
const callout = useShowCallout();
const controller = useRef(null);
const { identifier, criteria } = useSearchParams();
const { showErrorMessage } = useErrorMessages();

const { fileUpload } = useUpload();
const { bulkOperationStart } = useBulkOperationStart();
Expand Down Expand Up @@ -102,7 +104,7 @@ const BulkEditManualUploadModal = ({
id: operationId,
step: EDITING_STEPS.COMMIT,
approach: APPROACHES.MANUAL,
});
}).then(showErrorMessage);

setCountOfRecords(committedNumOfRecords);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ export const IdentifierTab = () => {

setIsFileUploaded(true);
} catch (error) {
showErrorMessage(error, { fileName: fileToUpload.name });
showErrorMessage({ errorMessage: error.message }, { fileName: fileToUpload.name });
}
};

Expand Down
4 changes: 0 additions & 4 deletions src/hooks/api/useBulkOperationStart.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,10 @@ import {
JOB_STATUSES,
EDITING_STEPS,
} from '../../constants';
import { useErrorMessages } from '../useErrorMessages';

export const useBulkOperationStart = (mutationOptions = {}) => {
const params = useRef({});
const ky = useOkapiKy();
const { showErrorMessage } = useErrorMessages();

const { refetch: fetchBulkOperation } = useQuery({
queryFn: async () => {
Expand Down Expand Up @@ -71,8 +69,6 @@ export const useBulkOperationStart = (mutationOptions = {}) => {

return data;
},
onSuccess: showErrorMessage,
onError: showErrorMessage,
...mutationOptions,
});

Expand Down
4 changes: 1 addition & 3 deletions src/hooks/useConfirmChanges.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,7 @@ export const useConfirmChanges = ({
approach: APPROACHES.IN_APP,
step: EDITING_STEPS.EDIT,
}))
.then((response) => {
showErrorMessage(response);
})
.then(showErrorMessage)
.catch((error) => {
showErrorMessage(error);
closePreviewModal();
Expand Down

0 comments on commit 8ee9722

Please sign in to comment.