"use server"; 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 { filename: string; blobValue: Uint8Array; } export const fetchProjectCashFlowReport = async (data: ProjectCashFlowReportRequest) => { const reportBlob = await serverFetchBlob( `${BASE_API_URL}/reports/ProjectCashFlowReport`, { method: "POST", body: JSON.stringify(data), headers: { "Content-Type": "application/json" }, }, ); 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`, { method: "POST", body: JSON.stringify(data), headers: { "Content-Type": "application/json" }, }, ); return reportBlob }; export const fetchProjectResourceOverconsumptionReport = async (data: ProjectResourceOverconsumptionReportRequest) => { const reportBlob = await serverFetchBlob( `${BASE_API_URL}/reports/ProjectResourceOverconsumptionReport`, { method: "POST", body: JSON.stringify(data), headers: { "Content-Type": "application/json" }, }, ); 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`, // { // method: "POST", // body: JSON.stringify(data), // headers: { "Content-Type": "application/json" }, // }, // ); // return response; // }; export const fetchLateStartReport = async (data: LateStartReportRequest) => { const response = await serverFetchBlob(`${BASE_API_URL}/reports/downloadLateStartReport`, { method: "POST", body: JSON.stringify(data), headers: { "Content-Type": "application/json" }, }); return response }; export const fetchProjectPandLReport = async (data: ProjectPandLReportRequest) => { const reportBlob = await serverFetchBlob( `${BASE_API_URL}/reports/projectpandlreport`, { method: "POST", body: JSON.stringify(data), headers: { "Content-Type": "application/json" }, }, ); return reportBlob };