Skip to content

Commit

Permalink
ADM-873:[frontend]fix: fix notification logic (#1356)
Browse files Browse the repository at this point in the history
Co-authored-by: yulongcai <141199398+yulongcai@users.noreply.github.com>
  • Loading branch information
TingyuDong and yulongcai authored Apr 12, 2024
1 parent 505a7b6 commit 2f0e75a
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions frontend/src/containers/ReportStep/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ const ReportStep = ({ handleSave }: ReportStepProps) => {

const [exportValidityTimeMin, setExportValidityTimeMin] = useState<number | undefined | null>(undefined);
const [pageType, setPageType] = useState<string>(REPORT_PAGE_TYPE.SUMMARY);
const [isSuccessfulCreateCsvFile, setIsSuccessfulCreateCsvFile] = useState<boolean>(false);
const [isCsvFileGeneratedAtEnd, setIsCsvFileGeneratedAtEnd] = useState<boolean>(false);
const [notifications4SummaryPage, setNotifications4SummaryPage] = useState<Omit<Notification, 'id'>[]>([]);

const configData = useAppSelector(selectConfig);
Expand Down Expand Up @@ -210,16 +210,16 @@ const ReportStep = ({ handleSave }: ReportStepProps) => {

useLayoutEffect(() => {
exportValidityTimeMin &&
isSuccessfulCreateCsvFile &&
isCsvFileGeneratedAtEnd &&
dispatch(
addNotification({
message: MESSAGE.EXPIRE_INFORMATION(exportValidityTimeMin),
}),
);
}, [dispatch, exportValidityTimeMin, isSuccessfulCreateCsvFile]);
}, [dispatch, exportValidityTimeMin, isCsvFileGeneratedAtEnd]);

useLayoutEffect(() => {
if (exportValidityTimeMin && isSuccessfulCreateCsvFile) {
if (exportValidityTimeMin && isCsvFileGeneratedAtEnd) {
const startTime = Date.now();
const timer = setInterval(() => {
const currentTime = Date.now();
Expand All @@ -241,15 +241,15 @@ const ReportStep = ({ handleSave }: ReportStepProps) => {
clearInterval(timer);
};
}
}, [dispatch, exportValidityTimeMin, isSuccessfulCreateCsvFile]);
}, [dispatch, exportValidityTimeMin, isCsvFileGeneratedAtEnd]);

useLayoutEffect(() => {
dispatch(closeAllNotifications());
}, [dispatch, pageType]);

useEffect(() => {
setExportValidityTimeMin(reportData?.exportValidityTime);
reportData && setIsSuccessfulCreateCsvFile(reportData.isSuccessfulCreateCsvFile);
reportData && setIsCsvFileGeneratedAtEnd(reportData.allMetricsCompleted && reportData.isSuccessfulCreateCsvFile);
}, [dispatch, reportData]);

useEffect(() => {
Expand Down

0 comments on commit 2f0e75a

Please sign in to comment.