From 2c54e80b9fb1f0a805bea089c26be76c18cb745c Mon Sep 17 00:00:00 2001 From: "MSI\\2Fi" Date: Thu, 16 May 2024 20:39:01 +0800 Subject: [PATCH] gen financail status report --- .../FinancialStatusReportGen.tsx | 20 +++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx b/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx index 775e849..f3f7108 100644 --- a/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx +++ b/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx @@ -40,12 +40,20 @@ const GenFinancialStatusReport: React.FC = ({ projects, projectCombo }) = { - const projectIndex = projectCombo.findIndex((project) => `${project.code} - ${project.name}` === query.code) - console.log(projectCombo[projectIndex].id) - const response = await fetchProjectsFinancialStatusReport({ projectId: projects[projectIndex].id }) - if (response) { - downloadFile(new Uint8Array(response.blobValue), response.filename!!) - } + if (query.code.length > 0 && query.code.toLocaleLowerCase() !== "all") { + const projectIndex = projectCombo.findIndex((project) => `${project.code} - ${project.name}` === query.code) + console.log(projectCombo[projectIndex].id) + const response = await fetchProjectsFinancialStatusReport({ projectId: projects[projectIndex].id }) + if (response) { + downloadFile(new Uint8Array(response.blobValue), response.filename!!) + } + }else{ + console.log(query.code) + const response = await fetchProjectsFinancialStatusReport({ projectId: -1 }) + if (response) { + downloadFile(new Uint8Array(response.blobValue), response.filename!!) + } + } }} /> {/* */}