Browse Source

update

tags/Baseline_30082024_FRONTEND_UAT
MSI\derek 1 year ago
parent
commit
ed66ffebd4
2 changed files with 51 additions and 1 deletions
  1. +35
    -0
      src/app/api/team/actions.ts
  2. +16
    -1
      src/app/api/team/index.ts

+ 35
- 0
src/app/api/team/actions.ts View File

@@ -2,6 +2,33 @@
import { serverFetchJson } from "@/app/utils/fetchUtil"; import { serverFetchJson } from "@/app/utils/fetchUtil";
import { BASE_API_URL } from "@/config/api"; import { BASE_API_URL } from "@/config/api";
import { cache } from "react"; import { cache } from "react";
import { Staff, StaffGroup } from "../staff";
import { TeamResult } from ".";


export interface CreateTeamInputs {
id: number | null;
// name: string;
// team: string;
// staffId: string;
// grade: string;
// joinPosition: string;
// currentPosition: string;
description: String;
addStaffIds: number[];
deleteStaffIds?: number[];
}

export interface Team {
id: number;
name: string;
}

export interface staff {
id: number;
name: string;
team: Team;
}


export interface comboProp { export interface comboProp {
id: any; id: any;
@@ -17,3 +44,11 @@ export const fetchTeamCombo = cache(async () => {
next: { tags: ["team"] }, next: { tags: ["team"] },
}); });
}); });

export const saveTeam = async (data: CreateTeamInputs) => {
return serverFetchJson(`${BASE_API_URL}/team/save`, {
method: "POST",
body: JSON.stringify(data),
headers: { "Content-Type": "application/json" },
});
};

+ 16
- 1
src/app/api/team/index.ts View File

@@ -7,14 +7,29 @@ import "server-only";
export interface TeamResult { export interface TeamResult {
action: any; action: any;
id: number; id: number;
teamId: number;
name: string; name: string;
code: string; code: string;
description: string; description: string;
}
staffId: string;
staffName: string;
posLabel: string;
posCode: string;


}
export const fetchTeam = cache(async () => { export const fetchTeam = cache(async () => {
return serverFetchJson<TeamResult[]>(`${BASE_API_URL}/team`, { return serverFetchJson<TeamResult[]>(`${BASE_API_URL}/team`, {
next: { tags: ["team"] }, next: { tags: ["team"] },
}); });
});

export const preloadTeamDetail = () => {
fetchTeamDetail();
};

export const fetchTeamDetail = cache(async () => {
return serverFetchJson<TeamResult[]>(`${BASE_API_URL}/team/detail`, {
next: { tags: ["team"] },
});
}); });

Loading…
Cancel
Save