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.
 
 

101 line
4.1 KiB

  1. "use server";
  2. import { cache } from "react";
  3. import { serverFetchJson } from "@/app/utils/fetchUtil";
  4. import { BASE_API_URL } from "@/config/api";
  5. export interface comboProp {
  6. id: any;
  7. label: string;
  8. }
  9. export interface teamCombo {
  10. records: comboProp[];
  11. }
  12. export interface weeklyTeamTotalManhoursSpentResult {
  13. weeklyActualTeamTotalManhoursSpent: any[];
  14. weeklyPlannedTeamTotalManhoursSpent: any[];
  15. }
  16. export interface monthlyTeamTotalManhoursSpentResult {
  17. monthlyActualTeamTotalManhoursSpent: any[];
  18. monthlyPlannedTeamTotalManhoursSpent: any[];
  19. }
  20. export interface totalManhourByGradeResult {
  21. staffGradeTotalManhours: any[];
  22. staffGradeTotalPlannedManhours: any[];
  23. }
  24. export interface weeklyUnsubmitResult {
  25. id: number;
  26. name: string;
  27. teamId: number;
  28. UnsubmittedCount: number;
  29. }
  30. export interface records {
  31. id: number;
  32. name: string;
  33. label: string;
  34. // team: Team[];
  35. }
  36. export interface IndividualStaffManhoursDaily {
  37. individualStaffManhoursSpentByDay: any[];
  38. individualStaffTotalManhoursSpentByDay: any[];
  39. individualStaffTotalLeaveHoursByDay: any[];
  40. }
  41. export interface IndividualStaffManhoursWeekly {
  42. individualStaffManhoursSpentWeekly: any[];
  43. individualStaffTotalManhoursSpentWeekly: any[];
  44. individualStaffTotalLeaveHoursWeekly: any[];
  45. }
  46. export interface IndividualStaffManhoursMonthly {
  47. individualStaffManhoursSpentByMonth: any[];
  48. individualStaffTotalManhoursSpentByMonth: any[];
  49. individualStaffTotalLeaveHoursByMonth: any[];
  50. }
  51. export const fetchTeamCombo = cache(async () => {
  52. return serverFetchJson<teamCombo>(`${BASE_API_URL}/team/combo`);
  53. });
  54. export const fetchweeklyTeamTotalManhours = cache(async (teamId: number, startdate:string) => {
  55. return serverFetchJson<weeklyTeamTotalManhoursSpentResult[]>(`${BASE_API_URL}/dashboard/searchWeeklyActualTeamTotalManhoursSpent?teamId=${teamId}&startdate=${startdate}`);
  56. });
  57. export const fetchmonthlyTeamTotalManhours = cache(async (teamId: number, startdate:string, enddate:string) => {
  58. return serverFetchJson<monthlyTeamTotalManhoursSpentResult[]>(`${BASE_API_URL}/dashboard/searchMonthlyActualTeamTotalManhoursSpent?teamId=${teamId}&startdate=${startdate}&enddate=${enddate}`);
  59. });
  60. export const fetchTotalManhoursByGrade = cache(async (startdate:string, enddate:string, teamId:number) => {
  61. return serverFetchJson<totalManhourByGradeResult[]>(`${BASE_API_URL}/dashboard/searchTotalManhoursSpentByStaffGrade?startdate=${startdate}&enddate=${enddate}&teamId=${teamId}`);
  62. });
  63. export const fetchWeeklyUnsubmit = cache(async (teamId:number,startdate:string, publicHolidayList:string) => {
  64. return serverFetchJson<weeklyUnsubmitResult[]>(`${BASE_API_URL}/dashboard/searchWeeklyUnsubmittedTimeSheet?teamId=${teamId}&startdate=${startdate}&publicHolidayList=${publicHolidayList}`);
  65. });
  66. export const fetchMonthlyUnsubmit = cache(async (teamId:number,startdate:string, enddate:string, publicHolidayList:string) => {
  67. return serverFetchJson<weeklyUnsubmitResult[]>(`${BASE_API_URL}/dashboard/searchMonthlyUnsubmittedTimeSheet?teamId=${teamId}&startdate=${startdate}&enddate=${enddate}&publicHolidayList=${publicHolidayList}`);
  68. });
  69. export const fetchStaffCombo = cache(async () => {
  70. return serverFetchJson<records[]>(`${BASE_API_URL}/dashboard/searchStaffCombo`, {
  71. next: { tags: ["staffs"] },
  72. });
  73. });
  74. export const fetchDailyIndividualStaffManhours = cache(async (staffId:number,startdate:string) => {
  75. return serverFetchJson<IndividualStaffManhoursDaily[]>(`${BASE_API_URL}/dashboard/searchTotalManhoursSpentByStaffDaily?staffId=${staffId}&startdate=${startdate}`);
  76. });
  77. export const fetchWeeklyIndividualStaffManhours = cache(async (staffId:number,startdate:string, enddate:string) => {
  78. return serverFetchJson<IndividualStaffManhoursWeekly[]>(`${BASE_API_URL}/dashboard/searchTotalManhoursSpentByStaffWeekly?staffId=${staffId}&startdate=${startdate}&enddate=${enddate}`);
  79. });
  80. export const fetchMonthlyIndividualStaffManhours = cache(async (staffId:number,startdate:string) => {
  81. return serverFetchJson<IndividualStaffManhoursMonthly[]>(`${BASE_API_URL}/dashboard/searchTotalManhoursSpentByStaffByMonth?staffId=${staffId}&startdate=${startdate}`);
  82. });