diff --git a/src/app/(main)/analytics/ProjectCompletionReport/page.tsx b/src/app/(main)/analytics/ProjectCompletionReport/page.tsx
index 8a13941..e277d3a 100644
--- a/src/app/(main)/analytics/ProjectCompletionReport/page.tsx
+++ b/src/app/(main)/analytics/ProjectCompletionReport/page.tsx
@@ -1,24 +1,28 @@
//src\app\(main)\analytics\ProjectCompletionReport\page.tsx
import { Metadata } from "next";
-import { I18nProvider } from "@/i18n";
+import { I18nProvider, getServerI18n } from "@/i18n";
import Typography from "@mui/material/Typography";
-import ProjectCompletionReportComponent from "@/components/Report/ProjectCompletionReport";
+import { Suspense } from "react";
+import ProjectCompletionReport from "@/components/ProjectCompletionReport";
export const metadata: Metadata = {
title: "Project Completion Report",
};
-const ProjectCompletionReport: React.FC = () => {
+const ProjectCompletionReportPage: React.FC = async () => {
+ const { t } = await getServerI18n("report");
+
return (
-
-
- Project Completion Report
+ <>
+
+ {t("Project Completion Report")}
- {/* }>
-
- */}
-
-
+
+ }>
+
+
+
+ >
);
};
-export default ProjectCompletionReport;
+export default ProjectCompletionReportPage;
diff --git a/src/app/api/reports/actions.ts b/src/app/api/reports/actions.ts
index ff874ba..2d3c09e 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 } from ".";
+import { MonthlyWorkHoursReportRequest, ProjectCashFlowReportRequest, LateStartReportRequest, ProjectResourceOverconsumptionReportRequest, ProjectPandLReportRequest, ProjectCompletionReportRequest } from ".";
import { BASE_API_URL } from "@/config/api";
export interface FileResponse {
@@ -48,6 +48,19 @@ export const fetchProjectResourceOverconsumptionReport = async (data: ProjectRes
return reportBlob
};
+export const fetchProjectCompletionReport = async (data: ProjectCompletionReportRequest) => {
+ const reportBlob = await serverFetchBlob(
+ `${BASE_API_URL}/reports/ProjectCompletionReportwithOutstandingAccountsReceivable`,
+ {
+ method: "POST",
+ body: JSON.stringify(data),
+ headers: { "Content-Type": "application/json" },
+ },
+ );
+
+ return reportBlob
+};
+
// export const fetchLateStartReport = async (data: LateStartReportRequest) => {
// const response = await serverFetchBlob(
// `${BASE_API_URL}/reports/downloadLateStartReport`,
diff --git a/src/app/api/reports/index.ts b/src/app/api/reports/index.ts
index 0691005..7779e14 100644
--- a/src/app/api/reports/index.ts
+++ b/src/app/api/reports/index.ts
@@ -65,3 +65,15 @@ export interface LateStartReportRequest {
client: string;
date: any;
}
+
+export interface ProjectCompletionReportFilter {
+ startDate: String;
+ startDateTo: String;
+ Outstanding: String;
+}
+
+export interface ProjectCompletionReportRequest {
+ startDate: String;
+ endDate: String;
+ outstanding: Boolean;
+}
diff --git a/src/components/NavigationContent/NavigationContent.tsx b/src/components/NavigationContent/NavigationContent.tsx
index 0ed436c..0d8521f 100644
--- a/src/components/NavigationContent/NavigationContent.tsx
+++ b/src/components/NavigationContent/NavigationContent.tsx
@@ -162,11 +162,11 @@ const NavigationContent: React.FC = ({ abilities }) => {
label: "Completion Report",
path: "/analytics/ProjectCompletionReport",
},
- {
- icon: ,
- label: "Completion Report with Outstanding Un-billed Hours Report",
- path: "/analytics/ProjectCompletionReportWO",
- },
+ // {
+ // icon: ,
+ // label: "Completion Report with Outstanding Un-billed Hours Report",
+ // path: "/analytics/ProjectCompletionReportWO",
+ // },
{
icon: ,
label: "Project Claims Report",
diff --git a/src/components/ProjectCompletionReport/ProjectCompletionReport.tsx b/src/components/ProjectCompletionReport/ProjectCompletionReport.tsx
new file mode 100644
index 0000000..397c27a
--- /dev/null
+++ b/src/components/ProjectCompletionReport/ProjectCompletionReport.tsx
@@ -0,0 +1,95 @@
+"use client";
+import {
+ ProjectCompletionReportFilter,
+ ProjectCompletionReportRequest,
+} from "@/app/api/reports";
+import React, { useMemo, useState } from "react";
+import { useTranslation } from "react-i18next";
+import SearchBox, { Criterion } from "../SearchBox";
+import dayjs from "dayjs";
+import { INPUT_DATE_FORMAT } from "@/app/utils/formatUtil";
+import { downloadFile } from "@/app/utils/commonUtil";
+import { fetchProjectCompletionReport } from "@/app/api/reports/actions";
+
+interface Props {
+ // team: TeamResult[]
+ // customer: Customer[]
+}
+
+type SearchQuery = Partial>;
+type SearchParamNames = keyof SearchQuery;
+
+const ProjectCompletionReport: React.FC = (
+ {
+ // team,
+ // customer
+ }
+) => {
+ const { t } = useTranslation("report");
+ const [error, setError] = useState("");
+ const outstandingList = ["Regular", "Outstanding Accounts Receivable"]
+
+ const searchCriteria: Criterion[] = useMemo(
+ () => [
+ {
+ label: t("startDate"),
+ label2: t("endDate"),
+ paramName: "startDate",
+ type: "dateRange",
+ },
+ {
+ label: t("Type"),
+ paramName: "Outstanding",
+ type: "select",
+ needAll: false,
+ options: outstandingList
+ },
+ ],
+ [t]
+ );
+
+ return (
+ <>
+ {
+ console.log(query);
+ let postData: ProjectCompletionReportRequest = {
+ startDate: "",
+ endDate: dayjs().format(INPUT_DATE_FORMAT).toString(),
+ oustanding: false
+ };
+ if (query.endDate && query.endDate.length > 0) {
+ postData.endDate = query.endDate;
+ }
+
+ // check if start date exist
+ if (query.startDate.length === 0) {
+ setError(t("Start Date cant be empty"));
+ } else {
+ postData.startDate = query.startDate;
+ if (query.Outstanding && query.Outstanding === "Outstanding Accounts Receivable") {
+ // outstanding report
+ postData.outstanding = true
+ }
+ console.log(postData)
+ const response =
+ await fetchProjectCompletionReport(
+ postData
+ );
+ // normal report
+
+ if (response) {
+ downloadFile(
+ new Uint8Array(response.blobValue),
+ response.filename!!
+ );
+ }
+ }
+ }}
+ />
+ >
+ );
+};
+
+export default ProjectCompletionReport;
diff --git a/src/components/ProjectCompletionReport/ProjectCompletionReportLoading.tsx b/src/components/ProjectCompletionReport/ProjectCompletionReportLoading.tsx
new file mode 100644
index 0000000..1c5355c
--- /dev/null
+++ b/src/components/ProjectCompletionReport/ProjectCompletionReportLoading.tsx
@@ -0,0 +1,41 @@
+//src\components\LateStartReportGen\LateStartReportGenLoading.tsx
+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 ProjectCompletionReportLoading: React.FC = () => {
+ return (
+ <>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ >
+ );
+};
+
+export default ProjectCompletionReportLoading;
diff --git a/src/components/ProjectCompletionReport/ProjectCompletionReportWrapper.tsx b/src/components/ProjectCompletionReport/ProjectCompletionReportWrapper.tsx
new file mode 100644
index 0000000..0dd10cb
--- /dev/null
+++ b/src/components/ProjectCompletionReport/ProjectCompletionReportWrapper.tsx
@@ -0,0 +1,18 @@
+import React from "react";
+import { fetchAllCustomers } from "@/app/api/customer";
+import { fetchTeam } from "@/app/api/team";
+import ProjectCompletionReportLoading from "./ProjectCompletionReportLoading";
+import ProjectCompletionReport from "./ProjectCompletionReport";
+
+interface SubComponents {
+ Loading: typeof ProjectCompletionReportLoading;
+}
+
+const ProjectCompletionReportWrapper: React.FC & SubComponents = async () => {
+
+ return
+};
+
+ProjectCompletionReportWrapper.Loading = ProjectCompletionReportLoading;
+
+export default ProjectCompletionReportWrapper;
\ No newline at end of file
diff --git a/src/components/ProjectCompletionReport/index.ts b/src/components/ProjectCompletionReport/index.ts
new file mode 100644
index 0000000..8555938
--- /dev/null
+++ b/src/components/ProjectCompletionReport/index.ts
@@ -0,0 +1 @@
+export { default } from "./ProjectCompletionReportWrapper";
\ No newline at end of file