|
|
@@ -1,22 +1,30 @@ |
|
|
|
//src\components\LateStartReportGen\LateStartReportGen.tsx |
|
|
|
"use client"; |
|
|
|
import React, { useMemo, useState } from "react"; |
|
|
|
import SearchBox, { Criterion } from "../ReportSearchBoxe1"; |
|
|
|
// import SearchBox, { Criterion } from "../ReportSearchBoxe1"; |
|
|
|
import { useTranslation } from "react-i18next"; |
|
|
|
import { FinancialStatus } from "@/app/api/reporte1"; |
|
|
|
import { FinancialStatus, ProjectCombo } from "@/app/api/reporte1"; |
|
|
|
import SearchBox, { Criterion } from "@/components/SearchBox"; |
|
|
|
import { FinancialStatusReportFilter } from "@/app/api/reports"; |
|
|
|
import { fetchAllClientSubsidiaryProjects } from "@/app/api/clientprojects/actions"; |
|
|
|
import { fetchProjectsFinancialStatusReport } from "@/app/api/reporte1/action"; |
|
|
|
import { downloadFile } from "@/app/utils/commonUtil"; |
|
|
|
//import { DownloadReportButton } from './DownloadReportButton'; |
|
|
|
interface Props { |
|
|
|
projects: FinancialStatus[]; |
|
|
|
projectCombo : ProjectCombo[]; |
|
|
|
} |
|
|
|
type SearchQuery = Partial<Omit<FinancialStatus, "id">>; |
|
|
|
type SearchQuery = Partial<Omit<ProjectCombo, "id">>; |
|
|
|
type SearchParamNames = keyof SearchQuery; |
|
|
|
|
|
|
|
const ProgressByClientSearch: React.FC<Props> = ({ projects }) => { |
|
|
|
const GenFinancialStatusReport: React.FC<Props> = ({ projects, projectCombo }) => { |
|
|
|
const { t } = useTranslation("projects"); |
|
|
|
|
|
|
|
const combo = projectCombo.map(project => {return `${project.code} - ${project.name}`}) |
|
|
|
|
|
|
|
const searchCriteria: Criterion<SearchParamNames>[] = useMemo( |
|
|
|
() => [ |
|
|
|
{ label: "{Project Code}", paramName: "projectCode", type: "select", options: ["M1234", "M1268", "M1352", "M1393"] }, |
|
|
|
{ label: t("Project No"), paramName: "code", type: "select", options: combo, }, |
|
|
|
// { |
|
|
|
// label: "Status", |
|
|
|
// label2: "Remained Date To", |
|
|
@@ -31,8 +39,13 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects }) => { |
|
|
|
<> |
|
|
|
<SearchBox |
|
|
|
criteria={searchCriteria} |
|
|
|
onSearch={(query) => { |
|
|
|
console.log(query); |
|
|
|
onSearch={async (query) => { |
|
|
|
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!!) |
|
|
|
} |
|
|
|
}} |
|
|
|
/> |
|
|
|
{/* <DownloadReportButton /> */} |
|
|
@@ -40,4 +53,4 @@ const ProgressByClientSearch: React.FC<Props> = ({ projects }) => { |
|
|
|
); |
|
|
|
}; |
|
|
|
|
|
|
|
export default ProgressByClientSearch; |
|
|
|
export default GenFinancialStatusReport; |