diff --git a/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js b/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js index 52f2f920..1a7bcf6f 100644 --- a/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js +++ b/src/components/BulkEditPane/BulkEditListSidebar/IdentifierTab/IdentifierTab.js @@ -4,7 +4,7 @@ import React, { useMemo, useState } from 'react'; -import { buildSearch, useShowCallout } from '@folio/stripes-acq-components'; +import { buildSearch } from '@folio/stripes-acq-components'; import { FormattedMessage } from 'react-intl'; import { useHistory, useLocation } from 'react-router-dom'; @@ -24,12 +24,13 @@ import { useBulkPermissions, useLocationFilters, useSearchParams } from '../../. import { useBulkOperationStart, useUpload } from '../../../../hooks/api'; import { getIsDisabledByPerm } from '../utils/getIsDisabledByPerm'; import { RootContext } from '../../../../context/RootContext'; +import { useErrorMessages } from '../../../../hooks/useErrorMessages'; export const IdentifierTab = () => { const history = useHistory(); const location = useLocation(); - const showCallout = useShowCallout(); const permissions = useBulkPermissions(); + const { showErrorMessage } = useErrorMessages(); const { isFileUploaded, @@ -146,7 +147,7 @@ export const IdentifierTab = () => { }); if (errorMessage?.includes(ERRORS.TOKEN)) throw Error(ERRORS.TOKEN); - if (status === JOB_STATUSES.FAILED) throw Error(); + if (status === JOB_STATUSES.FAILED) throw Error(errorMessage); history.replace({ pathname: `/bulk-edit/${id}/preview`, @@ -155,13 +156,8 @@ export const IdentifierTab = () => { } setIsFileUploaded(true); - } catch ({ message }) { - if (message === ERRORS.TOKEN) { - showCallout({ - message: , - type: 'error', - }); - } + } catch (error) { + showErrorMessage(error); } }; diff --git a/src/components/shared/ProgressBar/ProgressBar.js b/src/components/shared/ProgressBar/ProgressBar.js index f764ff48..fe046070 100644 --- a/src/components/shared/ProgressBar/ProgressBar.js +++ b/src/components/shared/ProgressBar/ProgressBar.js @@ -34,14 +34,13 @@ export const ProgressBar = () => { useEffect(() => { const nextStep = getBulkOperationStep(bulkDetails); - // Show error message if any - showErrorMessage(bulkDetails); - if (nextStep) { clearIntervalAndRedirect(`/bulk-edit/${id}/preview`, { step: nextStep, progress: null }); } if (status === JOB_STATUSES.FAILED) { + showErrorMessage(bulkDetails); + clearIntervalAndRedirect('/bulk-edit', ''); } }, [