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!!) + } + } }} /> {/* */}