Ver a proveniência

Filter by Project to team

tags/Baseline_30082024_FRONTEND_UAT
MSI\2Fi há 1 ano
ascendente
cometimento
888a0b095b
3 ficheiros alterados com 15 adições e 15 eliminações
  1. +4
    -4
      src/app/api/reporte1/index.ts
  2. +8
    -8
      src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx
  3. +3
    -3
      src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx

+ 4
- 4
src/app/api/reporte1/index.ts Ver ficheiro

@@ -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<ProjectCombo[]>(`${BASE_API_URL}/projects`, {
next: { tags: ["projects"] },
export const fetchTeamCombo = cache(async () => {
return serverFetchJson<TeamCombo[]>(`${BASE_API_URL}/team/combo2`, {
next: { tags: ["teamCombo"] },
});
});



+ 8
- 8
src/components/Report/FinancialStatusReportGen/FinancialStatusReportGen.tsx Ver ficheiro

@@ -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!!)


+ 3
- 3
src/components/Report/FinancialStatusReportGen/FinancialStatusReportGenWrapper.tsx Ver ficheiro

@@ -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 <FinancialStatusReportGen projects={clentprojects} projectCombo={projectCombo}/>;
return <FinancialStatusReportGen projects={clentprojects} teamCombo={teamCombo}/>;
};

FinancialStatusReportGenWrapper.Loading = FinancialStatusReportGenLoading;


Carregando…
Cancelar
Guardar