diff --git a/src/app/api/team/actions.ts b/src/app/api/team/actions.ts index 4a371b0..492c03c 100644 --- a/src/app/api/team/actions.ts +++ b/src/app/api/team/actions.ts @@ -2,6 +2,33 @@ import { serverFetchJson } from "@/app/utils/fetchUtil"; import { BASE_API_URL } from "@/config/api"; 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 { id: any; @@ -17,3 +44,11 @@ export const fetchTeamCombo = cache(async () => { 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" }, + }); + }; diff --git a/src/app/api/team/index.ts b/src/app/api/team/index.ts index 81799d7..3aa872d 100644 --- a/src/app/api/team/index.ts +++ b/src/app/api/team/index.ts @@ -7,14 +7,29 @@ import "server-only"; export interface TeamResult { action: any; id: number; + teamId: number; name: string; code: string; description: string; - } + staffId: string; + staffName: string; + posLabel: string; + posCode: string; + } export const fetchTeam = cache(async () => { return serverFetchJson(`${BASE_API_URL}/team`, { next: { tags: ["team"] }, }); + }); + + export const preloadTeamDetail = () => { + fetchTeamDetail(); + }; + +export const fetchTeamDetail = cache(async () => { + return serverFetchJson(`${BASE_API_URL}/team/detail`, { + next: { tags: ["team"] }, + }); }); \ No newline at end of file