Skip to content

Commit

Permalink
Adm-879-fix [frontend]: fix the notification close logic (#1426)
Browse files Browse the repository at this point in the history
* ADM-879-fix fix: use the dispatch to update redux

* ADM-879-fix fix: fix test
  • Loading branch information
Leiqiuhong authored Apr 30, 2024
1 parent d3e5697 commit 79fe2d6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import { ReactNode } from 'react';
jest.mock('@src/context/notification/NotificationSlice', () => ({
...jest.requireActual('@src/context/notification/NotificationSlice'),
addNotification: jest.fn().mockReturnValue({ type: 'ADD_NOTIFICATION' }),
closeNotification: jest.fn(),
closeNotification: jest.fn().mockReturnValue({ type: 'CLOSE_NOTIFICATION' }),
}));

jest.mock('@src/context/stepper/StepperSlice', () => ({
Expand Down
10 changes: 7 additions & 3 deletions frontend/src/containers/ReportStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -228,14 +228,18 @@ const ReportStep = ({ handleSave }: ReportStepProps) => {
jiraBoardSetting: undefined,
};

useEffect(() => {
setCurrentDataInfo(reportInfos.find((singleResult) => singleResult.id === selectedDateRange.startDate)!);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [reportInfos, selectedDateRange]);

useEffect(() => {
notificationIds.forEach((notificationId) => {
closeNotification(notificationId);
dispatch(closeNotification(notificationId));
});
setNotificationIds([]);
setCurrentDataInfo(reportInfos.find((singleResult) => singleResult.id === selectedDateRange.startDate)!);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [reportInfos, selectedDateRange]);
}, [selectedDateRange]);

useEffect(() => {
setPageType(onlySelectClassification ? REPORT_PAGE_TYPE.BOARD : REPORT_PAGE_TYPE.SUMMARY);
Expand Down

0 comments on commit 79fe2d6

Please sign in to comment.