Quick fix
This commit is contained in:
@@ -9,7 +9,7 @@ import useExams from "@/hooks/useExams";
|
||||
import {useListSearch} from "@/hooks/useListSearch";
|
||||
import usePagination from "@/hooks/usePagination";
|
||||
import {Module} from "@/interfaces";
|
||||
import {EntityWithRoles} from "@/interfaces/entity";
|
||||
import {EntityWithRoles, WithEntity} from "@/interfaces/entity";
|
||||
import {InstructorGender, Variant} from "@/interfaces/exam";
|
||||
import {Assignment} from "@/interfaces/results";
|
||||
import {Group, User} from "@/interfaces/user";
|
||||
@@ -20,6 +20,7 @@ import {getEntitiesWithRoles} from "@/utils/entities.be";
|
||||
import {getGroups, getGroupsByEntities} from "@/utils/groups.be";
|
||||
import {checkAccess, findAllowedEntities} from "@/utils/permissions";
|
||||
import {calculateAverageLevel} from "@/utils/score";
|
||||
import { isAdmin } from "@/utils/users";
|
||||
import {getEntitiesUsers, getUsers} from "@/utils/users.be";
|
||||
import axios from "axios";
|
||||
import clsx from "clsx";
|
||||
@@ -45,15 +46,15 @@ export const getServerSideProps = withIronSessionSsr(async ({req, res}) => {
|
||||
const allowedEntities = findAllowedEntities(user, entities, 'create_assignment')
|
||||
if (allowedEntities.length === 0) return redirect("/assignments")
|
||||
|
||||
const users = await (checkAccess(user, ["developer", "admin"]) ? getUsers() : getEntitiesUsers(mapBy(allowedEntities, 'id')));
|
||||
const groups = await (checkAccess(user, ["developer", "admin"]) ? getGroups() : getGroupsByEntities(mapBy(allowedEntities, 'id')));
|
||||
const users = await (isAdmin(user) ? getUsers() : getEntitiesUsers(mapBy(allowedEntities, 'id')));
|
||||
const groups = await (isAdmin(user) ? getGroups() : getGroupsByEntities(mapBy(allowedEntities, 'id')));
|
||||
|
||||
return {props: serialize({user, users, entities, groups})};
|
||||
}, sessionOptions);
|
||||
|
||||
interface Props {
|
||||
assignment: Assignment;
|
||||
groups: Group[];
|
||||
groups: WithEntity<Group>[];
|
||||
user: User;
|
||||
users: User[];
|
||||
entities: EntityWithRoles[];
|
||||
@@ -95,7 +96,7 @@ export default function AssignmentsPage({user, users, groups, entities}: Props)
|
||||
const {exams} = useExams();
|
||||
const router = useRouter();
|
||||
|
||||
const classrooms = useMemo(() => groups.filter((e) => e.entity === entity), [entity, groups]);
|
||||
const classrooms = useMemo(() => groups.filter((e) => e.entity?.id === entity), [entity, groups]);
|
||||
const allowedUsers = useMemo(() => users.filter((u) => mapBy(u.entities, 'id').includes(entity || "")), [users, entity])
|
||||
|
||||
const userStudents = useMemo(() => allowedUsers.filter((x) => x.type === "student"), [allowedUsers]);
|
||||
|
||||
Reference in New Issue
Block a user