@@ -2,10 +2,10 @@ import { Metadata } from "next"; | |||||
import { Suspense } from "react"; | import { Suspense } from "react"; | ||||
import { I18nProvider } from "@/i18n"; | import { I18nProvider } from "@/i18n"; | ||||
import { fetchProjects } from "@/app/api/projects"; | import { fetchProjects } from "@/app/api/projects"; | ||||
import GenerateEX02ProjectCashFlowReport from "@/components/GenerateEX02ProjectCashFlowReport"; | |||||
import GenerateProjectCashFlowReport from "@/components/GenerateProjectCashFlowReport"; | |||||
export const metadata: Metadata = { | export const metadata: Metadata = { | ||||
title: "EX02 - Project Cash Flow Report", | |||||
title: "Project Cash Flow Report", | |||||
}; | }; | ||||
const ProjectCashFlowReport: React.FC = async () => { | const ProjectCashFlowReport: React.FC = async () => { | ||||
@@ -14,8 +14,8 @@ const ProjectCashFlowReport: React.FC = async () => { | |||||
return ( | return ( | ||||
<> | <> | ||||
<I18nProvider namespaces={["report", "common"]}> | <I18nProvider namespaces={["report", "common"]}> | ||||
<Suspense fallback={<GenerateEX02ProjectCashFlowReport.Loading />}> | |||||
<GenerateEX02ProjectCashFlowReport /> | |||||
<Suspense fallback={<GenerateProjectCashFlowReport.Loading />}> | |||||
<GenerateProjectCashFlowReport /> | |||||
</Suspense> | </Suspense> | ||||
</I18nProvider> | </I18nProvider> | ||||
</> | </> |
@@ -1,7 +1,7 @@ | |||||
"use server"; | "use server"; | ||||
import { serverFetchBlob, serverFetchJson } from "@/app/utils/fetchUtil"; | import { serverFetchBlob, serverFetchJson } from "@/app/utils/fetchUtil"; | ||||
import { EX02ProjectCashFlowReportRequest } from "."; | |||||
import { ProjectCashFlowReportRequest } from "."; | |||||
import { BASE_API_URL } from "@/config/api"; | import { BASE_API_URL } from "@/config/api"; | ||||
export interface FileResponse { | export interface FileResponse { | ||||
@@ -9,9 +9,9 @@ export interface FileResponse { | |||||
blobValue: Uint8Array; | blobValue: Uint8Array; | ||||
} | } | ||||
export const fetchEX02ProjectCashFlowReport = async (data: EX02ProjectCashFlowReportRequest) => { | |||||
export const fetchProjectCashFlowReport = async (data: ProjectCashFlowReportRequest) => { | |||||
const reportBlob = await serverFetchBlob<FileResponse>( | const reportBlob = await serverFetchBlob<FileResponse>( | ||||
`${BASE_API_URL}/reports/EX02-ProjectCashFlowReport`, | |||||
`${BASE_API_URL}/reports/ProjectCashFlowReport`, | |||||
{ | { | ||||
method: "POST", | method: "POST", | ||||
body: JSON.stringify(data), | body: JSON.stringify(data), | ||||
@@ -1,8 +1,8 @@ | |||||
// EX02 - Project Cash Flow Report | |||||
export interface EX02ProjectCashFlowReportFilter { | |||||
// - Project Cash Flow Report | |||||
export interface ProjectCashFlowReportFilter { | |||||
project: string[]; | project: string[]; | ||||
} | } | ||||
export interface EX02ProjectCashFlowReportRequest { | |||||
export interface ProjectCashFlowReportRequest { | |||||
projectId: number; | projectId: number; | ||||
} | } |
@@ -29,7 +29,7 @@ const pathToLabelMap: { [path: string]: string } = { | |||||
"/settings/position": "Position", | "/settings/position": "Position", | ||||
"/settings/position/new": "Create Position", | "/settings/position/new": "Create Position", | ||||
"/settings/salarys": "Salary", | "/settings/salarys": "Salary", | ||||
"/analytics/EX02ProjectCashFlowReport": "EX02 - Project Cash Flow Report", | |||||
"/analytics/ProjectCashFlowReport": "Project Cash Flow Report", | |||||
}; | }; | ||||
const Breadcrumb = () => { | const Breadcrumb = () => { | ||||
@@ -1,18 +0,0 @@ | |||||
import React from "react"; | |||||
import GenerateEX02ProjectCashFlowReportLoading from "./GenerateEX02ProjectCashFlowReportLoading"; | |||||
import { fetchProjects } from "@/app/api/projects"; | |||||
import GenerateEX02ProjectCashFlowReport from "./GenerateEX02ProjectCashFlowReport"; | |||||
interface SubComponents { | |||||
Loading: typeof GenerateEX02ProjectCashFlowReportLoading; | |||||
} | |||||
const GenerateEX02ProjectCashFlowReportWrapper: React.FC & SubComponents = async () => { | |||||
const projects = await fetchProjects(); | |||||
return <GenerateEX02ProjectCashFlowReport projects={projects} />; | |||||
}; | |||||
GenerateEX02ProjectCashFlowReportWrapper.Loading = GenerateEX02ProjectCashFlowReportLoading; | |||||
export default GenerateEX02ProjectCashFlowReportWrapper; |
@@ -1 +0,0 @@ | |||||
export { default } from "./GenerateEX02ProjectCashFlowReportWrapper"; |
@@ -4,8 +4,8 @@ import React, { useMemo } from "react"; | |||||
import SearchBox, { Criterion } from "../SearchBox"; | import SearchBox, { Criterion } from "../SearchBox"; | ||||
import { useTranslation } from "react-i18next"; | import { useTranslation } from "react-i18next"; | ||||
import { ProjectResult } from "@/app/api/projects"; | 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 { downloadFile } from "@/app/utils/commonUtil"; | ||||
import { BASE_API_URL } from "@/config/api"; | import { BASE_API_URL } from "@/config/api"; | ||||
@@ -13,10 +13,10 @@ interface Props { | |||||
projects: ProjectResult[]; | projects: ProjectResult[]; | ||||
} | } | ||||
type SearchQuery = Partial<Omit<EX02ProjectCashFlowReportFilter, "id">>; | |||||
type SearchQuery = Partial<Omit<ProjectCashFlowReportFilter, "id">>; | |||||
type SearchParamNames = keyof SearchQuery; | type SearchParamNames = keyof SearchQuery; | ||||
const GenerateEX02ProjectCashFlowReport: React.FC<Props> = ({ projects }) => { | |||||
const GenerateProjectCashFlowReport: React.FC<Props> = ({ projects }) => { | |||||
const { t } = useTranslation(); | const { t } = useTranslation(); | ||||
const projectCombo = projects.map(project => `${project.code} - ${project.name}`) | 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") { | if (query.project.length > 0 && query.project.toLocaleLowerCase() !== "all") { | ||||
const projectIndex = projectCombo.findIndex(project => project === query.project) | 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) { | if (response) { | ||||
downloadFile(new Uint8Array(response.blobValue), response.filename!!) | downloadFile(new Uint8Array(response.blobValue), response.filename!!) | ||||
} | } | ||||
@@ -46,4 +46,4 @@ const GenerateEX02ProjectCashFlowReport: React.FC<Props> = ({ projects }) => { | |||||
); | ); | ||||
}; | }; | ||||
export default GenerateEX02ProjectCashFlowReport; | |||||
export default GenerateProjectCashFlowReport; |
@@ -5,7 +5,7 @@ import Stack from "@mui/material/Stack"; | |||||
import React from "react"; | import React from "react"; | ||||
// Can make this nicer | // Can make this nicer | ||||
export const GenerateEX02ProjectCashFlowReportLoading: React.FC = () => { | |||||
export const GenerateProjectCashFlowReportLoading: React.FC = () => { | |||||
return ( | return ( | ||||
<> | <> | ||||
<Card> | <Card> | ||||
@@ -35,4 +35,4 @@ export const GenerateEX02ProjectCashFlowReportLoading: React.FC = () => { | |||||
); | ); | ||||
}; | }; | ||||
export default GenerateEX02ProjectCashFlowReportLoading; | |||||
export default GenerateProjectCashFlowReportLoading; |
@@ -0,0 +1,18 @@ | |||||
import React from "react"; | |||||
import GenerateProjectCashFlowReportLoading from "./GenerateProjectCashFlowReportLoading"; | |||||
import { fetchProjects } from "@/app/api/projects"; | |||||
import GenerateProjectCashFlowReport from "./GenerateProjectCashFlowReport"; | |||||
interface SubComponents { | |||||
Loading: typeof GenerateProjectCashFlowReportLoading; | |||||
} | |||||
const GenerateProjectCashFlowReportWrapper: React.FC & SubComponents = async () => { | |||||
const projects = await fetchProjects(); | |||||
return <GenerateProjectCashFlowReport projects={projects} />; | |||||
}; | |||||
GenerateProjectCashFlowReportWrapper.Loading = GenerateProjectCashFlowReportLoading; | |||||
export default GenerateProjectCashFlowReportWrapper; |
@@ -0,0 +1 @@ | |||||
export { default } from "./GenerateProjectCashFlowReportWrapper"; |
@@ -118,7 +118,7 @@ const navigationItems: NavigationItem[] = [ | |||||
{icon: <Analytics />, label:"Project Claims Report", path: "/analytics/ProjectClaimsReport"}, | {icon: <Analytics />, label:"Project Claims Report", path: "/analytics/ProjectClaimsReport"}, | ||||
{icon: <Analytics />, label:"Project P&L Report", path: "/analytics/ProjectPLReport"}, | {icon: <Analytics />, label:"Project P&L Report", path: "/analytics/ProjectPLReport"}, | ||||
{icon: <Analytics />, label:"Financial Status Report", path: "/analytics/FinancialStatusReport"}, | {icon: <Analytics />, label:"Financial Status Report", path: "/analytics/FinancialStatusReport"}, | ||||
{icon: <Analytics />, label:"EX02 - Project Cash Flow Report", path: "/analytics/EX02ProjectCashFlowReport"}, | |||||
{icon: <Analytics />, label:"Project Cash Flow Report", path: "/analytics/ProjectCashFlowReport"}, | |||||
], | ], | ||||
}, | }, | ||||
{ | { | ||||