Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UIBULKED-553 Prevent duplication of errors for bulk operation start (follow up) #633

Merged
merged 1 commit into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading