瀏覽代碼

update

tags/Baseline_30082024_FRONTEND_UAT
MSI\derek 1 年之前
父節點
當前提交
93df71e310
共有 3 個文件被更改,包括 28 次插入38 次删除
  1. +0
    -6
      src/components/EditTeam/Allocation.tsx
  2. +27
    -29
      src/components/EditTeam/EditTeam.tsx
  3. +1
    -3
      src/components/EditTeam/TeamInfo.tsx

+ 0
- 6
src/components/EditTeam/Allocation.tsx 查看文件

@@ -62,10 +62,6 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
); );
const [deletedStaffIds, setDeletedStaffIds] = useState<number[]>([]); const [deletedStaffIds, setDeletedStaffIds] = useState<number[]>([]);


console.log(getValues("addStaffIds"));
console.log(filteredStaff);
console.log(selectedStaff)

// Adding / Removing staff // Adding / Removing staff
const addStaff = useCallback((staff: StaffResult) => { const addStaff = useCallback((staff: StaffResult) => {
setSelectedStaff((s) => [...s, staff]); setSelectedStaff((s) => [...s, staff]);
@@ -88,8 +84,6 @@ const Allocation: React.FC<Props> = ({ allStaffs: staff, teamLead }) => {
}, },
getValues("addStaffIds") getValues("addStaffIds")
); );
// console.log(rearrangedList);
// console.log(selectedStaff);


const rearrangedStaff = rearrangedList.map((id) => { const rearrangedStaff = rearrangedList.map((id) => {
return selectedStaff.find((staff) => staff.id === id); return selectedStaff.find((staff) => staff.id === id);


+ 27
- 29
src/components/EditTeam/EditTeam.tsx 查看文件

@@ -30,8 +30,8 @@ const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => {
const formProps = useForm<CreateTeamInputs>(); const formProps = useForm<CreateTeamInputs>();
const searchParams = useSearchParams(); const searchParams = useSearchParams();
const idString = searchParams.get("id"); const idString = searchParams.get("id");
const [allStaffs, setAllStaffs] = useState<StaffResult[]>();
const [teamLead, setTeamLead] = useState<number>();
// const [allStaffs, setAllStaffs] = useState<StaffResult[]>();
// const [teamLead, setTeamLead] = useState<number>();
const [tabIndex, setTabIndex] = useState(0); const [tabIndex, setTabIndex] = useState(0);
const router = useRouter(); const router = useRouter();


@@ -46,34 +46,33 @@ const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => {


const [serverError, setServerError] = useState(""); const [serverError, setServerError] = useState("");


useEffect(() => {
let idList: number[] = [];
// console.log(desc)
if (idString) {
const filteredTeam = staff.filter((item) => {
return item.teamId === parseInt(idString);
});
console.log(team.teamLead);
setTeamLead(team.teamLead);
if (filteredTeam.length > 0) {
const filteredIds: number[] = filteredTeam.map((i) => i.id);
// 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);
// // const teamLead = tempDesc[0].teamLead
// // const index = filteredIds.indexOf(teamLead);


// if (index !== -1) {
// filteredIds.splice(index, 1);
// filteredIds.unshift(teamLead);
// }
// // if (index !== -1) {
// // filteredIds.splice(index, 1);
// // filteredIds.unshift(teamLead);
// // }


idList = filteredIds;
}
formProps.reset({ description: team.description, addStaffIds: idList });
}
// console.log(staff)
// idList = filteredIds;
// }
// formProps.reset({ description: team.description, addStaffIds: idList });
// }
// // console.log(staff)


setAllStaffs(staff);
}, [searchParams]);
// setAllStaffs(staff);
// }, [searchParams]);


const hasErrorsInTab = ( const hasErrorsInTab = (
tabIndex: number, tabIndex: number,
@@ -136,8 +135,7 @@ const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => {
onSubmit={formProps.handleSubmit(onSubmit)} onSubmit={formProps.handleSubmit(onSubmit)}
> >
<Typography variant="h4" marginInlineEnd={2}> <Typography variant="h4" marginInlineEnd={2}>
{t("Edit Team")}
{/* - {team.name} */}
{t("Edit Team")} - {team.name}
</Typography> </Typography>
<Stack <Stack
direction="row" direction="row"
@@ -164,7 +162,7 @@ const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => {
</Stack> </Stack>
{tabIndex === 0 && <TeamInfo />} {tabIndex === 0 && <TeamInfo />}
{tabIndex === 1 && ( {tabIndex === 1 && (
<Allocation allStaffs={allStaffs!!} teamLead={teamLead!!} />
<Allocation allStaffs={staff} teamLead={team.teamLead} />
)} )}
<Stack direction="row" justifyContent="flex-end" gap={1}> <Stack direction="row" justifyContent="flex-end" gap={1}>
<Button <Button


+ 1
- 3
src/components/EditTeam/TeamInfo.tsx 查看文件

@@ -77,9 +77,7 @@ const TeamInfo: React.FC<Props> = () => {
fullWidth fullWidth
multiline multiline
rows={4} rows={4}
{...register("description", {
required: true,
})}
{...register("description")}
error={Boolean(errors.description)} error={Boolean(errors.description)}
helperText={ helperText={
Boolean(errors.description) && Boolean(errors.description) &&


Loading…
取消
儲存