Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.
 
 

53 rindas
1.0 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 Staff {
  6. id: number;
  7. name: string;
  8. staffId: string;
  9. team: {
  10. name: string;
  11. code: string;
  12. };
  13. }
  14. export interface StaffResult {
  15. id: number;
  16. name: string;
  17. team: string;
  18. staffId: string;
  19. grade: string;
  20. joinPosition: string;
  21. currentPosition: string;
  22. }
  23. export interface searchInput {
  24. staffId: string;
  25. name: string;
  26. team: string;
  27. grade: string;
  28. currentPosition: string;
  29. }
  30. export const preloadTeamLeads = () => {
  31. fetchTeamLeads();
  32. // fetchStaff();
  33. };
  34. export const fetchTeamLeads = cache(async () => {
  35. return serverFetchJson<Staff[]>(`${BASE_API_URL}/staffs/teamLeads`, {
  36. next: { tags: ["teamLeads"] },
  37. });
  38. });
  39. export const preloadStaff = () => {
  40. fetchStaff();
  41. };
  42. export const fetchStaff = cache(async () => {
  43. return serverFetchJson<StaffResult[]>(`${BASE_API_URL}/staffs`, {
  44. next: { tags: ["staffs"] },
  45. });
  46. });