import { serverFetchJson } from "@/app/utils/fetchUtil"; import { BASE_API_URL } from "@/config/api"; import { cache } from "react"; import "server-only"; export interface data { [key: string]: any; } export interface StaffGroup { id: number; name: string; } export interface Staff { id: number; staffId: string; name: string; // description: string | null; currentPosition: StaffGroup; } export interface StaffTeamTable { id: number; staffId: string; name: string; // description: string | null; currentPosition: string; } export type IndivStaff = { data: IndividualStaff } export type IndividualStaff = { id: number staffId: string name: string company: data team: data department: data grade: data skill: data skillset: any currentPosition: data salary: data employType: string email: string phone1: string phone2?: string emergContactName: string; emergContactPhone: string; joinDate: string; joinPosition: data; departDate?: string; departReason?: string; remark?: string; } export interface StaffResult { action: any; id: number; name: string; team: string; staffId: string; grade: string; joinPosition: string; currentPosition: string; teamId: number; staffName: string; userId: number; companyId: number; data: data; } export interface searchInput { staffId: string; name: string; team: string; grade: string; currentPosition: string; } export interface SalaryEffectiveInfo { id: number; date: string; salaryPoint: number; } export const preloadTeamLeads = () => { fetchTeamLeads(); }; export const fetchTeamLeads = cache(async () => { return serverFetchJson(`${BASE_API_URL}/staffs/teamLeads`, { next: { tags: ["teamLeads"] }, }); }); export const preloadStaff = () => { fetchStaff(); }; export const fetchStaff = cache(async () => { return serverFetchJson(`${BASE_API_URL}/staffs`, { next: { tags: ["staffs"] }, }); }); export const fetchIndivStaff = cache(async (id: number) => { return serverFetchJson(`${BASE_API_URL}/staffs/${id}`, { next: { tags: ["staffs"] }, }); }); export const fetchStaffWithoutTeam = cache(async () => { return serverFetchJson(`${BASE_API_URL}/staffs/noteam`, { next: { tags: ["staffs"] }, }); }); // export const fetchStaffCombo = cache(async () => { // return serverFetchJson(`${BASE_API_URL}/staffs/combo`, { // next: { tags: ["staffs"] }, // }); // });