|
|
@@ -3,7 +3,7 @@ |
|
|
|
import React, { useMemo, useState } from "react"; |
|
|
|
// import SearchBox, { Criterion } from "../ReportSearchBoxe1"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import { FinancialStatus, ProjectCombo } from "@/app/api/reporte1"; |
|
|
|
import { FinancialStatus, TeamCombo } from "@/app/api/reporte1"; |
|
|
|
import SearchBox, { Criterion } from "@/components/SearchBox"; |
|
|
|
import { FinancialStatusReportFilter } from "@/app/api/reports"; |
|
|
|
import { fetchAllClientSubsidiaryProjects } from "@/app/api/clientprojects/actions"; |
|
|
@@ -12,19 +12,19 @@ import { downloadFile } from "@/app/utils/commonUtil"; |
|
|
|
//import { DownloadReportButton } from './DownloadReportButton'; |
|
|
|
interface Props { |
|
|
|
projects: FinancialStatus[]; |
|
|
|
projectCombo : ProjectCombo[]; |
|
|
|
teamCombo : TeamCombo[]; |
|
|
|
} |
|
|
|
type SearchQuery = Partial<Omit<ProjectCombo, "id">>; |
|
|
|
type SearchQuery = Partial<Omit<TeamCombo, "id">>; |
|
|
|
type SearchParamNames = keyof SearchQuery; |
|
|
|
|
|
|
|
const GenFinancialStatusReport: React.FC<Props> = ({ projects, projectCombo }) => { |
|
|
|
const GenFinancialStatusReport: React.FC<Props> = ({ projects, teamCombo }) => { |
|
|
|
const { t } = useTranslation("projects"); |
|
|
|
|
|
|
|
const combo = projectCombo.map(project => {return `${project.code} - ${project.name}`}) |
|
|
|
const combo = teamCombo.map(combo => {return `${combo.code} - ${combo.name}`}) |
|
|
|
|
|
|
|
const searchCriteria: Criterion<SearchParamNames>[] = useMemo( |
|
|
|
() => [ |
|
|
|
{ label: t("Project No"), paramName: "code", type: "select", options: combo, }, |
|
|
|
{ label: t("Team"), paramName: "code", type: "select", options: combo, }, |
|
|
|
// { |
|
|
|
// label: "Status", |
|
|
|
// label2: "Remained Date To", |
|
|
@@ -41,8 +41,8 @@ const GenFinancialStatusReport: React.FC<Props> = ({ projects, projectCombo }) = |
|
|
|
criteria={searchCriteria} |
|
|
|
onSearch={async (query) => { |
|
|
|
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 projectIndex = teamCombo.findIndex((project) => `${project.code} - ${project.name}` === query.code) |
|
|
|
console.log(teamCombo[projectIndex].id) |
|
|
|
const response = await fetchProjectsFinancialStatusReport({ projectId: projects[projectIndex].id }) |
|
|
|
if (response) { |
|
|
|
downloadFile(new Uint8Array(response.blobValue), response.filename!!) |
|
|
|