|
|
@@ -26,13 +26,10 @@ interface Props { |
|
|
|
|
|
|
|
const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => { |
|
|
|
const { team, staffIds } = teamInfo; |
|
|
|
// console.log(staffIds) |
|
|
|
const { t } = useTranslation(); |
|
|
|
const formProps = useForm<CreateTeamInputs>(); |
|
|
|
const searchParams = useSearchParams(); |
|
|
|
const idString = searchParams.get("id"); |
|
|
|
// const [allStaffs, setAllStaffs] = useState<StaffResult[]>(); |
|
|
|
// const [teamLead, setTeamLead] = useState<number>(); |
|
|
|
const [tabIndex, setTabIndex] = useState(0); |
|
|
|
const router = useRouter(); |
|
|
|
|
|
|
@@ -47,34 +44,6 @@ const EditTeam: React.FC<Props> = 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<CreateTeamInputs> |
|
|
@@ -165,7 +134,7 @@ const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => { |
|
|
|
</Stack> |
|
|
|
{tabIndex === 0 && <TeamInfo />} |
|
|
|
{tabIndex === 1 && ( |
|
|
|
<Allocation allStaffs={staff} teamLead={team.teamLead} /> |
|
|
|
<Allocation allStaffs={staff} teamLead={team.teamLead.id} /> |
|
|
|
)} |
|
|
|
<Stack direction="row" justifyContent="flex-end" gap={1}> |
|
|
|
<Button |
|
|
|