Improved the bug on the teachers

This commit is contained in:
Tiago Ribeiro
2024-08-20 00:10:26 +01:00
parent 688505b4eb
commit 4e583d11b6
2 changed files with 9 additions and 2 deletions

View File

@@ -121,7 +121,7 @@ export default function TeacherDashboard({user}: Props) {
};
const GroupsList = () => {
const filter = (x: Group) => x.admin === user.id || x.participants.includes(user.id);
const filter = (x: Group) => x.admin === user.id;
return (
<>

View File

@@ -212,6 +212,12 @@ export default function GroupList({user}: {user: User}) {
userType: user?.type,
});
const {groups: corporateGroups} = useGroups({
admin: user && filterTypes.includes(user?.type) ? user.id : undefined,
userType: user?.type,
adminAdmins: user?.id,
});
useEffect(() => {
if (user && ["corporate", "teacher", "mastercorporate"].includes(user.type)) {
setFilterByUser(true);
@@ -309,7 +315,8 @@ export default function GroupList({user}: {user: User}) {
groups
.filter((g) => g.admin === user.id)
.flatMap((g) => g.participants)
.includes(u.id) || groups.flatMap((g) => g.participants).includes(u.id),
.includes(u.id) ||
(user?.type === "teacher" ? corporateGroups : groups).flatMap((g) => g.participants).includes(u.id),
)
: users
}