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

PSP-6920 replace toast with warning modal #3861

Merged
merged 2 commits into from
Mar 12, 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 @@ -3,15 +3,16 @@ import fileDownload from 'js-file-download';
import { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { hideLoading, showLoading } from 'react-redux-loading-bar';
import { toast } from 'react-toastify';

import {
IPaginateAcquisition,
useApiAcquisitionFile,
} from '@/hooks/pims-api/useApiAcquisitionFile';
import { useModalContext } from '@/hooks/useModalContext';
import { logError, logRequest, logSuccess } from '@/store/slices/network/networkSlice';

export const useAcquisitionFileExport = () => {
const { setModalContent, setDisplayModal } = useModalContext();
const { exportAcquisitionFiles: apiExportAcquisitionFiles } = useApiAcquisitionFile();
const dispatch = useDispatch();

Expand All @@ -27,9 +28,13 @@ export const useAcquisitionFileExport = () => {
try {
const { data, status } = await apiExportAcquisitionFiles(filter);
if (status === 204) {
toast.warn(
"We were unable to retrieve any data for your request. If you've applied any filters or search criteria, ensure they are set correctly. Broadening your criteria may yield results.",
);
setModalContent({
variant: 'warning',
title: 'Warning',
message: 'There is no data for the input parameters you entered.',
okButtonText: 'Close',
});
setDisplayModal(true);
} else {
dispatch(logSuccess({ name: requestId, status }));
fileDownload(data, fileName);
Expand All @@ -48,7 +53,7 @@ export const useAcquisitionFileExport = () => {
}
}
},
[dispatch, apiExportAcquisitionFiles],
[dispatch, apiExportAcquisitionFiles, setModalContent, setDisplayModal],
);

return { exportAcquisitionFiles };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ import fileDownload from 'js-file-download';
import { useCallback } from 'react';
import { useDispatch } from 'react-redux';
import { hideLoading, showLoading } from 'react-redux-loading-bar';
import { toast } from 'react-toastify';

import {
IPaginateDisposition,
useApiDispositionFile,
} from '@/hooks/pims-api/useApiDispositionFile';
import { useModalContext } from '@/hooks/useModalContext';
import { logError, logRequest, logSuccess } from '@/store/slices/network/networkSlice';

export const useDispositionFileExport = () => {
const { setModalContent, setDisplayModal } = useModalContext();
const { exportDispositionFiles: apiExportDispositionFiles } = useApiDispositionFile();
const dispatch = useDispatch();

Expand All @@ -27,9 +28,13 @@ export const useDispositionFileExport = () => {
try {
const { data, status } = await apiExportDispositionFiles(filter);
if (status === 204) {
toast.warn(
"We were unable to retrieve any data for your request. If you've applied any filters or search criteria, ensure they are set correctly. Broadening your criteria may yield results.",
);
setModalContent({
variant: 'warning',
title: 'Warning',
message: 'There is no data for the input parameters you entered.',
okButtonText: 'Close',
});
setDisplayModal(true);
} else {
dispatch(logSuccess({ name: requestId, status }));
fileDownload(data, fileName);
Expand All @@ -48,7 +53,7 @@ export const useDispositionFileExport = () => {
}
}
},
[dispatch, apiExportDispositionFiles],
[dispatch, apiExportDispositionFiles, setModalContent, setDisplayModal],
);

return { exportDispositionFiles };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,12 @@ describe('OperationContainer component', () => {
renderOptions: RenderOptions & Partial<IOperationContainerProps> = { propertyId: 1 },
) => {
const { propertyId, ...rest } = renderOptions;
const component = render(
<OperationContainer propertyId={propertyId ?? 0} View={mockView} />,
{ ...rest, store: storeState, claims: [Claims.PROPERTY_VIEW], history },
);
const component = render(<OperationContainer propertyId={propertyId ?? 0} View={mockView} />, {
...rest,
store: storeState,
claims: [Claims.PROPERTY_VIEW],
history,
});

return { ...component };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ const history = createMemoryHistory();
const store = { [lookupCodesSlice.name]: { lookupCodes: mockLookups } };

describe('Subdivision detail view', () => {
const setup = (
renderOptions: RenderOptions & { props?: Partial<IOperationViewProps> } = {},
) => {
const setup = (renderOptions: RenderOptions & { props?: Partial<IOperationViewProps> } = {}) => {
const props = renderOptions.props;
const component = render(
<OperationView
Expand Down
Loading