|
|
@@ -4,8 +4,8 @@ import React, { useMemo } from "react"; |
|
|
|
import SearchBox, { Criterion } from "../SearchBox"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import { ProjectResult } from "@/app/api/projects"; |
|
|
|
import { EX02ProjectCashFlowReportFilter } from "@/app/api/reports"; |
|
|
|
import { fetchEX02ProjectCashFlowReport } from "@/app/api/reports/actions"; |
|
|
|
import { ProjectCashFlowReportFilter } from "@/app/api/reports"; |
|
|
|
import { fetchProjectCashFlowReport } from "@/app/api/reports/actions"; |
|
|
|
import { downloadFile } from "@/app/utils/commonUtil"; |
|
|
|
import { BASE_API_URL } from "@/config/api"; |
|
|
|
|
|
|
@@ -13,10 +13,10 @@ interface Props { |
|
|
|
projects: ProjectResult[]; |
|
|
|
} |
|
|
|
|
|
|
|
type SearchQuery = Partial<Omit<EX02ProjectCashFlowReportFilter, "id">>; |
|
|
|
type SearchQuery = Partial<Omit<ProjectCashFlowReportFilter, "id">>; |
|
|
|
type SearchParamNames = keyof SearchQuery; |
|
|
|
|
|
|
|
const GenerateEX02ProjectCashFlowReport: React.FC<Props> = ({ projects }) => { |
|
|
|
const GenerateProjectCashFlowReport: React.FC<Props> = ({ projects }) => { |
|
|
|
const { t } = useTranslation(); |
|
|
|
const projectCombo = projects.map(project => `${project.code} - ${project.name}`) |
|
|
|
|
|
|
@@ -35,7 +35,7 @@ const GenerateEX02ProjectCashFlowReport: React.FC<Props> = ({ projects }) => { |
|
|
|
|
|
|
|
if (query.project.length > 0 && query.project.toLocaleLowerCase() !== "all") { |
|
|
|
const projectIndex = projectCombo.findIndex(project => project === query.project) |
|
|
|
const response = await fetchEX02ProjectCashFlowReport({ projectId: projects[projectIndex].id }) |
|
|
|
const response = await fetchProjectCashFlowReport({ projectId: projects[projectIndex].id }) |
|
|
|
if (response) { |
|
|
|
downloadFile(new Uint8Array(response.blobValue), response.filename!!) |
|
|
|
} |
|
|
@@ -46,4 +46,4 @@ const GenerateEX02ProjectCashFlowReport: React.FC<Props> = ({ projects }) => { |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
export default GenerateEX02ProjectCashFlowReport; |
|
|
|
export default GenerateProjectCashFlowReport; |