Sfoglia il codice sorgente

update

tags/Baseline_30082024_FRONTEND_UAT
MSI\derek 1 anno fa
parent
commit
93df71e310
3 ha cambiato i file con 28 aggiunte e 38 eliminazioni
  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 Vedi File

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

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

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

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


+ 27
- 29
src/components/EditTeam/EditTeam.tsx Vedi File

@@ -30,8 +30,8 @@ const EditTeam: React.FC<Props> = async ({ staff, teamInfo }) => {
const formProps = useForm<CreateTeamInputs>();
const searchParams = useSearchParams();
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 router = useRouter();

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


+ 1
- 3
src/components/EditTeam/TeamInfo.tsx Vedi File

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


Caricamento…
Annulla
Salva