25'ten fazla konu seçemezsiniz Konular bir harf veya rakamla başlamalı, kısa çizgiler ('-') içerebilir ve en fazla 35 karakter uzunluğunda olabilir.
 
 

124 satır
2.5 KiB

  1. import { serverFetchJson } from "@/app/utils/fetchUtil";
  2. import { BASE_API_URL } from "@/config/api";
  3. import { cache } from "react";
  4. import "server-only";
  5. export interface data {
  6. [key: string]: any;
  7. }
  8. export interface StaffGroup {
  9. id: number;
  10. name: string;
  11. }
  12. export interface Staff {
  13. id: number;
  14. staffId: string;
  15. name: string;
  16. // description: string | null;
  17. currentPosition: StaffGroup;
  18. }
  19. export interface StaffTeamTable {
  20. id: number;
  21. staffId: string;
  22. name: string;
  23. // description: string | null;
  24. currentPosition: string;
  25. }
  26. export type IndivStaff = {
  27. data: IndividualStaff
  28. }
  29. export type IndividualStaff = {
  30. id: number
  31. staffId: string
  32. name: string
  33. company: data
  34. team: data
  35. department: data
  36. grade: data
  37. skill: data
  38. skillset: any
  39. currentPosition: data
  40. salary: data
  41. employType: string
  42. email: string
  43. phone1: string
  44. phone2?: string
  45. emergContactName: string;
  46. emergContactPhone: string;
  47. joinDate: string;
  48. joinPosition: data;
  49. departDate?: string;
  50. departReason?: string;
  51. remark?: string;
  52. }
  53. export interface StaffResult {
  54. action: any;
  55. id: number;
  56. name: string;
  57. team: string;
  58. staffId: string;
  59. grade: string;
  60. joinPosition: string;
  61. currentPosition: string;
  62. teamId: number;
  63. staffName: string;
  64. userId: number;
  65. companyId: number;
  66. data: data;
  67. }
  68. export interface searchInput {
  69. staffId: string;
  70. name: string;
  71. team: string;
  72. grade: string;
  73. currentPosition: string;
  74. }
  75. export interface SalaryEffectiveInfo {
  76. id: number;
  77. date: string;
  78. salaryPoint: number;
  79. }
  80. export const preloadTeamLeads = () => {
  81. fetchTeamLeads();
  82. };
  83. export const fetchTeamLeads = cache(async () => {
  84. return serverFetchJson<StaffResult[]>(`${BASE_API_URL}/staffs/teamLeads`, {
  85. next: { tags: ["teamLeads"] },
  86. });
  87. });
  88. export const preloadStaff = () => {
  89. fetchStaff();
  90. };
  91. export const fetchStaff = cache(async () => {
  92. return serverFetchJson<StaffResult[]>(`${BASE_API_URL}/staffs`, {
  93. next: { tags: ["staffs"] },
  94. });
  95. });
  96. export const fetchIndivStaff = cache(async (id: number) => {
  97. return serverFetchJson<IndivStaff>(`${BASE_API_URL}/staffs/${id}`, {
  98. next: { tags: ["staffs"] },
  99. });
  100. });
  101. export const fetchStaffWithoutTeam = cache(async () => {
  102. return serverFetchJson<StaffResult[]>(`${BASE_API_URL}/staffs/noteam`, {
  103. next: { tags: ["staffs"] },
  104. });
  105. });
  106. // export const fetchStaffCombo = cache(async () => {
  107. // return serverFetchJson<Staff4TransferList>(`${BASE_API_URL}/staffs/combo`, {
  108. // next: { tags: ["staffs"] },
  109. // });
  110. // });