From 888a0b095bcf92574af798229c46b629a42a6bf1 Mon Sep 17 00:00:00 2001 From: "MSI\\2Fi" Date: Fri, 17 May 2024 11:38:25 +0800 Subject: [PATCH] Filter by Project to team --- src/app/api/reporte1/index.ts | 8 ++++---- .../FinancialStatusReportGen.tsx | 16 ++++++++-------- .../FinancialStatusReportGenWrapper.tsx | 6 +++--- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/app/api/reporte1/index.ts b/src/app/api/reporte1/index.ts index b01df24..eb2cd24 100644 --- a/src/app/api/reporte1/index.ts +++ b/src/app/api/reporte1/index.ts @@ -18,7 +18,7 @@ export interface FinancialStatus { status: string; } -export interface ProjectCombo { +export interface TeamCombo { id: number; name: string; code: string; @@ -32,9 +32,9 @@ export const fetchProjectsFinancialStatus = cache(async () => { return mockProjects; }); -export const fetchProjectCombo = cache(async () => { - return serverFetchJson(`${BASE_API_URL}/projects`, { - next: { tags: ["projects"] }, +export const fetchTeamCombo = cache(async () => { + return serverFetchJson(`${BASE_API_URL}/team/combo2`, { + next: { tags: ["teamCombo"] }, }); }); diff --git a/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx b/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx index f3f7108..42fbee0 100644 --- a/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx +++ b/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx @@ -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>; +type SearchQuery = Partial>; type SearchParamNames = keyof SearchQuery; -const GenFinancialStatusReport: React.FC = ({ projects, projectCombo }) => { +const GenFinancialStatusReport: React.FC = ({ 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[] = 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 = ({ 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!!) diff --git a/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx b/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx index 7939307..601a1a7 100644 --- a/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx +++ b/src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx @@ -1,5 +1,5 @@ //src\components\LateStartReportGen\LateStartReportGenWrapper.tsx -import { fetchProjectCombo, fetchProjectsFinancialStatus } from "@/app/api/reporte1"; +import { fetchProjectsFinancialStatus, fetchTeamCombo } from "@/app/api/reporte1"; import React from "react"; import FinancialStatusReportGen from "./FinancialStatusReportGen"; import FinancialStatusReportGenLoading from "./FinancialStatusReportGenLoading"; @@ -11,9 +11,9 @@ interface SubComponents { const FinancialStatusReportGenWrapper: React.FC & SubComponents = async () => { const clentprojects = await fetchProjectsFinancialStatus(); - const projectCombo = await fetchProjectCombo() + const teamCombo = await fetchTeamCombo() - return ; + return ; }; FinancialStatusReportGenWrapper.Loading = FinancialStatusReportGenLoading;