diff --git a/src/app/(main)/analytics/DelayReport/page.tsx b/src/app/(main)/analytics/DelayReport/page.tsx
deleted file mode 100644
index 4c44218..0000000
--- a/src/app/(main)/analytics/DelayReport/page.tsx
+++ /dev/null
@@ -1,24 +0,0 @@
-//src\app\(main)\analytics\DelayReport\page.tsx
-import { Metadata } from "next";
-import { I18nProvider } from "@/i18n";
-import Typography from "@mui/material/Typography";
-import DelayReportComponent from "@/components/Report/DelayReport";
-
-export const metadata: Metadata = {
- title: "Delay Report",
-};
-
-const ProjectLateReport: React.FC = () => {
- return (
-
-
- Delay Report
-
- {/* }>
-
- */}
-
-
- );
-};
-export default ProjectLateReport;
diff --git a/src/app/(main)/analytics/ProjectPotentialDelayReport/page.tsx b/src/app/(main)/analytics/ProjectPotentialDelayReport/page.tsx
new file mode 100644
index 0000000..0ae0b29
--- /dev/null
+++ b/src/app/(main)/analytics/ProjectPotentialDelayReport/page.tsx
@@ -0,0 +1,33 @@
+//src\app\(main)\analytics\DelayReport\page.tsx
+import { Metadata } from "next";
+import { I18nProvider, getServerI18n } from "@/i18n";
+import Typography from "@mui/material/Typography";;
+import { fetchAllCustomers } from "@/app/api/customer";
+import { fetchTeam } from "@/app/api/team";
+import { Suspense } from "react";
+import GenerateProjectPotentialDelayReport from "@/components/GenerateProjectPotentialDelayReport";
+
+export const metadata: Metadata = {
+ title: "Project Potential Delay Report",
+};
+
+const ProjectPotentialDelayReport: React.FC = async () => {
+ const { t } = await getServerI18n("reports");
+
+ fetchAllCustomers()
+ fetchTeam()
+
+ return (
+ <>
+
+ {t("Project Potential Delay Report")}
+
+
+ }>
+
+
+
+ >
+ );
+};
+export default ProjectPotentialDelayReport;
diff --git a/src/app/api/reports/actions.ts b/src/app/api/reports/actions.ts
index c78f31f..c5046cb 100644
--- a/src/app/api/reports/actions.ts
+++ b/src/app/api/reports/actions.ts
@@ -1,7 +1,7 @@
"use server";
-import { serverFetchBlob, serverFetchJson } from "@/app/utils/fetchUtil";
-import { MonthlyWorkHoursReportRequest, ProjectCashFlowReportRequest, LateStartReportRequest, ProjectResourceOverconsumptionReportRequest, ProjectPandLReportRequest, ProjectCompletionReportRequest } from ".";
+import { serverFetchBlob } from "@/app/utils/fetchUtil";
+import { MonthlyWorkHoursReportRequest, ProjectCashFlowReportRequest, LateStartReportRequest, ProjectResourceOverconsumptionReportRequest, ProjectPandLReportRequest, ProjectCompletionReportRequest, ProjectPotentialDelayReportRequest } from ".";
import { BASE_API_URL } from "@/config/api";
export interface FileResponse {
@@ -22,6 +22,19 @@ export const fetchProjectCashFlowReport = async (data: ProjectCashFlowReportRequ
return reportBlob
};
+export const fetchProjectPotentialDelayReport = async (data: ProjectPotentialDelayReportRequest) => {
+ const reportBlob = await serverFetchBlob(
+ `${BASE_API_URL}/reports/ProjectPotentialDelayReport`,
+ {
+ method: "POST",
+ body: JSON.stringify(data),
+ headers: { "Content-Type": "application/json" },
+ },
+ );
+
+ return reportBlob
+};
+
export const fetchMonthlyWorkHoursReport = async (data: MonthlyWorkHoursReportRequest) => {
const reportBlob = await serverFetchBlob(
`${BASE_API_URL}/reports/StaffMonthlyWorkHourAnalysisReport`,
diff --git a/src/app/api/reports/index.ts b/src/app/api/reports/index.ts
index 361d531..cedc436 100644
--- a/src/app/api/reports/index.ts
+++ b/src/app/api/reports/index.ts
@@ -28,6 +28,16 @@ export interface ProjectCashFlowReportRequest {
dateType: string;
}
+// - Project Potential Delay Report
+export interface ProjectPotentialDelayReportFilter {
+ team: string[];
+ client: string[];
+}
+
+export interface ProjectPotentialDelayReportRequest {
+ teamId: number | "All";
+ clientId: number | "All";
+}
// - Monthly Work Hours Report
export interface MonthlyWorkHoursReportFilter {
diff --git a/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReport.tsx b/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReport.tsx
new file mode 100644
index 0000000..5d0d34f
--- /dev/null
+++ b/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReport.tsx
@@ -0,0 +1,53 @@
+"use client";
+
+import React, { useMemo } from "react";
+import SearchBox, { Criterion } from "../SearchBox";
+import { useTranslation } from "react-i18next";
+import { ProjectPotentialDelayReportFilter } from "@/app/api/reports";
+import { fetchProjectCashFlowReport, fetchProjectPotentialDelayReport } from "@/app/api/reports/actions";
+import { downloadFile } from "@/app/utils/commonUtil";
+import { TeamResult } from "@/app/api/team";
+import { Customer } from "@/app/api/customer";
+
+interface Props {
+ teams: TeamResult[];
+ clients: Customer[];
+}
+
+type SearchQuery = Partial>;
+type SearchParamNames = keyof SearchQuery;
+
+const GenerateProjectPotentialDelayReport: React.FC = ({ teams, clients }) => {
+ const { t } = useTranslation("report");
+ const teamCombo = teams.map(team => `${team.code} - ${team.name}`)
+ const clientCombo = clients.map(client => `${client.code} - ${client.name}`)
+
+ const searchCriteria: Criterion[] = useMemo(
+ () => [
+ { label: t("Team"), paramName: "team", type: "select", options: teamCombo },
+ { label: t("Client"), paramName: "client", type: "select", options: clientCombo },
+ ],
+ [t],
+ );
+
+ return (
+ <>
+ {
+
+ const teamIndex = teamCombo.findIndex(team => team === query.team)
+ const clientIndex = clientCombo.findIndex(client => client === query.client)
+
+ const response = await fetchProjectPotentialDelayReport({ teamId: teams[teamIndex]?.id ?? "All", clientId: clients[clientIndex]?.id ?? "All" })
+ if (response) {
+ downloadFile(new Uint8Array(response.blobValue), response.filename!!)
+ }
+ }}
+ formType={"download"}
+ />
+ >
+ );
+};
+
+export default GenerateProjectPotentialDelayReport;
\ No newline at end of file
diff --git a/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReportLoading.tsx b/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReportLoading.tsx
new file mode 100644
index 0000000..f501193
--- /dev/null
+++ b/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReportLoading.tsx
@@ -0,0 +1,38 @@
+import Card from "@mui/material/Card";
+import CardContent from "@mui/material/CardContent";
+import Skeleton from "@mui/material/Skeleton";
+import Stack from "@mui/material/Stack";
+import React from "react";
+
+// Can make this nicer
+export const GenerateProjectPotentialDelayReportLoading: React.FC = () => {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+
+export default GenerateProjectPotentialDelayReportLoading;
\ No newline at end of file
diff --git a/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReportWrapper.tsx b/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReportWrapper.tsx
new file mode 100644
index 0000000..51316c6
--- /dev/null
+++ b/src/components/GenerateProjectPotentialDelayReport/GenerateProjectPotentialDelayReportWrapper.tsx
@@ -0,0 +1,19 @@
+import React from "react";
+import GenerateProjectPotentialDelayReportLoading from "./GenerateProjectPotentialDelayReportLoading";
+import GenerateProjectPotentialDelayReport from "./GenerateProjectPotentialDelayReport";
+import { fetchTeam } from "@/app/api/team";
+import { fetchAllCustomers } from "@/app/api/customer";
+
+interface SubComponents {
+ Loading: typeof GenerateProjectPotentialDelayReportLoading;
+}
+
+const GenerateProjectPotentialDelayReportWrapper: React.FC & SubComponents = async () => {
+ const [teams, clients] = await Promise.all([fetchTeam(), fetchAllCustomers()])
+
+ return ;
+};
+
+GenerateProjectPotentialDelayReportWrapper.Loading = GenerateProjectPotentialDelayReportLoading;
+
+export default GenerateProjectPotentialDelayReportWrapper;
\ No newline at end of file
diff --git a/src/components/GenerateProjectPotentialDelayReport/index.ts b/src/components/GenerateProjectPotentialDelayReport/index.ts
new file mode 100644
index 0000000..e676d91
--- /dev/null
+++ b/src/components/GenerateProjectPotentialDelayReport/index.ts
@@ -0,0 +1 @@
+export { default } from "./GenerateProjectPotentialDelayReportWrapper";
\ No newline at end of file
diff --git a/src/components/NavigationContent/NavigationContent.tsx b/src/components/NavigationContent/NavigationContent.tsx
index 0d8521f..7fb2de8 100644
--- a/src/components/NavigationContent/NavigationContent.tsx
+++ b/src/components/NavigationContent/NavigationContent.tsx
@@ -144,8 +144,8 @@ const NavigationContent: React.FC = ({ abilities }) => {
},
{
icon: ,
- label: "Delay Report",
- path: "/analytics/DelayReport",
+ label: "Project Potential Delay Report",
+ path: "/analytics/ProjectPotentialDelayReport",
},
{
icon: ,