From a4c3057c4bdaf4510ed8b956df07804feebfa162 Mon Sep 17 00:00:00 2001 From: "MSI\\2Fi" Date: Fri, 26 Jul 2024 15:35:06 +0800 Subject: [PATCH] update --- .../GenerateProjectPandLReport.tsx | 38 ++++++++++--------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/src/components/GenerateProjectPandLReport/GenerateProjectPandLReport.tsx b/src/components/GenerateProjectPandLReport/GenerateProjectPandLReport.tsx index 3f89165..6727078 100644 --- a/src/components/GenerateProjectPandLReport/GenerateProjectPandLReport.tsx +++ b/src/components/GenerateProjectPandLReport/GenerateProjectPandLReport.tsx @@ -53,27 +53,29 @@ const GenerateProjectPandLReport: React.FC & SubComponents = ({ projects criteria={searchCriteria} onSearch={async (query) => { setLoading(true); - if (Boolean(query.project) && query.project !== "All") { - if(query.project != null && query.startMonth != "" && query.startMonthTo != undefined){ - const response = await fetchProjectPandLReport({ projectId: parseFloat(query.project), startMonth: query.startMonth, endMonth: query.startMonthTo }) - try{ + if (query.project && query.project !== "All") { + if (query.project && query.startMonth && query.startMonthTo) { + try { + const response = await fetchProjectPandLReport({ + projectId: parseFloat(query.project), + startMonth: query.startMonth, + endMonth: query.startMonthTo + }); if (response) { - downloadFile(new Uint8Array(response.blobValue), response.filename!!) + downloadFile(new Uint8Array(response.blobValue), response.filename); } - }catch(error){ - errorDialogWithContent(t("Download Fail"), - t(`Please try it later`), t) - .then(() => { - window.location.reload() - }) + } catch (error) { + errorDialogWithContent(t("Download Fail"), t("Please try it later"), t) + .then(() => { + window.location.reload(); + }); } - }else{ - errorDialogWithContent(t("Download Fail"), - t(`Please check the required field`), t) - .then(() => { - window.location.reload() - }) - } + } else { + errorDialogWithContent(t("Download Fail"), t("Please check the required field"), t) + .then(() => { + window.location.reload(); + }); + } } setLoading(false); }}