From f3c4ec44bce1c45cf5991c0cb6143786471e3ea6 Mon Sep 17 00:00:00 2001 From: "MSI\\derek" Date: Tue, 9 Jul 2024 14:26:42 +0800 Subject: [PATCH] update --- src/app/api/team/index.ts | 4 +++- src/components/EditTeam/EditTeam.tsx | 33 +--------------------------- 2 files changed, 4 insertions(+), 33 deletions(-) diff --git a/src/app/api/team/index.ts b/src/app/api/team/index.ts index 9ae4a5a..6a2ef1b 100644 --- a/src/app/api/team/index.ts +++ b/src/app/api/team/index.ts @@ -2,6 +2,7 @@ import { serverFetchJson } from "@/app/utils/fetchUtil"; import { BASE_API_URL } from "@/config/api"; import { cache } from "react"; import "server-only"; +import { IndividualStaff } from "../staff"; export interface TeamResult { action: any; @@ -27,7 +28,8 @@ export type IndividualTeam = { description: string; name: string; code: string; - teamLead: number; + teamLead: IndividualStaff; + staff: IndividualStaff; } export interface comboProp { diff --git a/src/components/EditTeam/EditTeam.tsx b/src/components/EditTeam/EditTeam.tsx index 77dae8b..33036d2 100644 --- a/src/components/EditTeam/EditTeam.tsx +++ b/src/components/EditTeam/EditTeam.tsx @@ -26,13 +26,10 @@ interface Props { const EditTeam: React.FC = async ({ staff, teamInfo }) => { const { team, staffIds } = teamInfo; - // console.log(staffIds) const { t } = useTranslation(); const formProps = useForm(); const searchParams = useSearchParams(); const idString = searchParams.get("id"); - // const [allStaffs, setAllStaffs] = useState(); - // const [teamLead, setTeamLead] = useState(); const [tabIndex, setTabIndex] = useState(0); const router = useRouter(); @@ -47,34 +44,6 @@ const EditTeam: React.FC = async ({ staff, teamInfo }) => { const [serverError, setServerError] = useState(""); - // useEffect(() => { - // let idList: number[] = []; - // // console.log(desc) - // if (idString) { - // const filteredTeam = staff.filter((item) => { - // return item.teamId === parseInt(idString); - // }); - // setTeamLead(team.teamLead); - // if (filteredTeam.length > 0) { - // const filteredIds: number[] = filteredTeam.map((i) => i.id); - - // // const teamLead = tempDesc[0].teamLead - // // const index = filteredIds.indexOf(teamLead); - - // // if (index !== -1) { - // // filteredIds.splice(index, 1); - // // filteredIds.unshift(teamLead); - // // } - - // idList = filteredIds; - // } - // formProps.reset({ description: team.description, addStaffIds: idList }); - // } - // // console.log(staff) - - // setAllStaffs(staff); - // }, [searchParams]); - const hasErrorsInTab = ( tabIndex: number, errors: FieldErrors @@ -165,7 +134,7 @@ const EditTeam: React.FC = async ({ staff, teamInfo }) => { {tabIndex === 0 && } {tabIndex === 1 && ( - + )}