You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

112 lines
3.6 KiB

  1. "use server";
  2. import { serverFetchBlob } from "@/app/utils/fetchUtil";
  3. import { MonthlyWorkHoursReportRequest, ProjectCashFlowReportRequest, LateStartReportRequest, ProjectResourceOverconsumptionReportRequest, ProjectPandLReportRequest, ProjectCompletionReportRequest, ProjectPotentialDelayReportRequest } from ".";
  4. import { BASE_API_URL } from "@/config/api";
  5. export interface FileResponse {
  6. filename: string;
  7. blobValue: Uint8Array;
  8. }
  9. export const fetchProjectCashFlowReport = async (data: ProjectCashFlowReportRequest) => {
  10. const reportBlob = await serverFetchBlob<FileResponse>(
  11. `${BASE_API_URL}/reports/ProjectCashFlowReport`,
  12. {
  13. method: "POST",
  14. body: JSON.stringify(data),
  15. headers: { "Content-Type": "application/json" },
  16. },
  17. );
  18. return reportBlob
  19. };
  20. export const fetchProjectPotentialDelayReport = async (data: ProjectPotentialDelayReportRequest) => {
  21. const reportBlob = await serverFetchBlob<FileResponse>(
  22. `${BASE_API_URL}/reports/ProjectPotentialDelayReport`,
  23. {
  24. method: "POST",
  25. body: JSON.stringify(data),
  26. headers: { "Content-Type": "application/json" },
  27. },
  28. );
  29. return reportBlob
  30. };
  31. export const fetchMonthlyWorkHoursReport = async (data: MonthlyWorkHoursReportRequest) => {
  32. const reportBlob = await serverFetchBlob<FileResponse>(
  33. `${BASE_API_URL}/reports/StaffMonthlyWorkHourAnalysisReport`,
  34. {
  35. method: "POST",
  36. body: JSON.stringify(data),
  37. headers: { "Content-Type": "application/json" },
  38. },
  39. );
  40. return reportBlob
  41. };
  42. export const fetchProjectResourceOverconsumptionReport = async (data: ProjectResourceOverconsumptionReportRequest) => {
  43. const reportBlob = await serverFetchBlob<FileResponse>(
  44. `${BASE_API_URL}/reports/ProjectResourceOverconsumptionReport`,
  45. {
  46. method: "POST",
  47. body: JSON.stringify(data),
  48. headers: { "Content-Type": "application/json" },
  49. },
  50. );
  51. return reportBlob
  52. };
  53. export const fetchProjectCompletionReport = async (data: ProjectCompletionReportRequest) => {
  54. const reportBlob = await serverFetchBlob<FileResponse>(
  55. `${BASE_API_URL}/reports/ProjectCompletionReportwithOutstandingAccountsReceivable`,
  56. {
  57. method: "POST",
  58. body: JSON.stringify(data),
  59. headers: { "Content-Type": "application/json" },
  60. },
  61. );
  62. return reportBlob
  63. };
  64. // export const fetchLateStartReport = async (data: LateStartReportRequest) => {
  65. // const response = await serverFetchBlob<FileResponse>(
  66. // `${BASE_API_URL}/reports/downloadLateStartReport`,
  67. // {
  68. // method: "POST",
  69. // body: JSON.stringify(data),
  70. // headers: { "Content-Type": "application/json" },
  71. // },
  72. // );
  73. // return response;
  74. // };
  75. export const fetchLateStartReport = async (data: LateStartReportRequest) => {
  76. const response = await serverFetchBlob<FileResponse>(`${BASE_API_URL}/reports/downloadLateStartReport`, {
  77. method: "POST",
  78. body: JSON.stringify(data),
  79. headers: { "Content-Type": "application/json" },
  80. });
  81. return response
  82. };
  83. export const fetchProjectPandLReport = async (data: ProjectPandLReportRequest) => {
  84. const reportBlob = await serverFetchBlob<FileResponse>(
  85. `${BASE_API_URL}/reports/projectpandlreport`,
  86. {
  87. method: "POST",
  88. body: JSON.stringify(data),
  89. headers: { "Content-Type": "application/json" },
  90. },
  91. );
  92. return reportBlob
  93. };