From 62e536a4207b402ed8eea8cfe4fd7f74ffbfaa02 Mon Sep 17 00:00:00 2001 From: "MSI\\2Fi" Date: Tue, 13 Aug 2024 15:37:52 +0800 Subject: [PATCH] fetch salaryEffective Info --- src/app/api/staff/index.ts | 6 ++++++ src/components/EditStaff/EditStaffWrapper.tsx | 7 +++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/app/api/staff/index.ts b/src/app/api/staff/index.ts index 1a4cfd3..240b821 100644 --- a/src/app/api/staff/index.ts +++ b/src/app/api/staff/index.ts @@ -116,6 +116,12 @@ export const fetchStaffWithoutTeam = cache(async () => { }); }); +export const fetchStaffSalaryEffectiveInfo = cache(async (id: number) => { + return serverFetchJson(`${BASE_API_URL}/salaryEffective?staffId=${id}`, { + next: { tags: ["staffs"] }, + }); +}); + // export const fetchStaffCombo = cache(async () => { // return serverFetchJson(`${BASE_API_URL}/staffs/combo`, { // next: { tags: ["staffs"] }, diff --git a/src/components/EditStaff/EditStaffWrapper.tsx b/src/components/EditStaff/EditStaffWrapper.tsx index 52951ca..3382362 100644 --- a/src/components/EditStaff/EditStaffWrapper.tsx +++ b/src/components/EditStaff/EditStaffWrapper.tsx @@ -1,7 +1,7 @@ import React from "react"; import EditStaff, { comboItem } from "./EditStaff"; import EditStaffLoading from "./EditStaffLoading"; -import { StaffResult, fetchIndivStaff, fetchStaff, fetchTeamLeads, preloadStaff } from "@/app/api/staff"; +import { StaffResult, fetchIndivStaff, fetchStaff, fetchStaffSalaryEffectiveInfo, fetchTeamLeads, preloadStaff } from "@/app/api/staff"; import { useSearchParams } from "next/navigation"; import { fetchTeamCombo } from "@/app/api/team/actions"; import { fetchDepartmentCombo } from "@/app/api/departments/actions"; @@ -32,6 +32,7 @@ const EditStaffWrapper: React.FC & SubComponents = async ({ GradeCombo, SkillCombo, SalaryCombo, + SalaryEffectiveInfo, ] = await Promise.all([ fetchIndivStaff(id), fetchCompanyCombo(), @@ -41,6 +42,7 @@ const EditStaffWrapper: React.FC & SubComponents = async ({ fetchGradeCombo(), fetchSkillCombo(), fetchSalaryCombo(), + fetchStaffSalaryEffectiveInfo(id), ]); console.log(SalaryCombo.records) @@ -54,9 +56,10 @@ const EditStaffWrapper: React.FC & SubComponents = async ({ salary: SalaryCombo.records, } +// [{id:0, salaryPoint: 1, date:"2021-05-05"}, {id:1, salaryPoint: 43, date:"2024-05-05"}] console.log(Staff.data) - return ; + return ; }; EditStaffWrapper.Loading = EditStaffLoading;