Fixed the thing with the entity users
This commit is contained in:
@@ -10,13 +10,13 @@ import {Entity, EntityWithRoles, Role} from "@/interfaces/entity";
|
||||
import {GroupWithUsers, User} from "@/interfaces/user";
|
||||
import {sessionOptions} from "@/lib/session";
|
||||
import {USER_TYPE_LABELS} from "@/resources/user";
|
||||
import { findBy, redirect, serialize } from "@/utils";
|
||||
import { findBy, mapBy, redirect, serialize } from "@/utils";
|
||||
import {getEntityWithRoles} from "@/utils/entities.be";
|
||||
import {convertToUsers, getGroup} from "@/utils/groups.be";
|
||||
import {shouldRedirectHome} from "@/utils/navigation.disabled";
|
||||
import {checkAccess, doesEntityAllow, getTypesOfUser} from "@/utils/permissions";
|
||||
import {getUserName} from "@/utils/users";
|
||||
import {getEntityUsers, getLinkedUsers, getSpecificUsers} from "@/utils/users.be";
|
||||
import {getUserName, isAdmin} from "@/utils/users";
|
||||
import {getEntitiesUsers, getEntityUsers, getLinkedUsers, getSpecificUsers, getUsers} from "@/utils/users.be";
|
||||
import { Menu, MenuButton, MenuItem, MenuItems } from "@headlessui/react";
|
||||
import axios from "axios";
|
||||
import clsx from "clsx";
|
||||
@@ -55,7 +55,7 @@ export const getServerSideProps = withIronSessionSsr(async ({req, params}) => {
|
||||
|
||||
if (!doesEntityAllow(user, entity, "view_entities")) return redirect(`/entities`)
|
||||
|
||||
const linkedUsers = await getLinkedUsers(user.id, user.type);
|
||||
const linkedUsers = await (isAdmin(user) ? getUsers() : getEntitiesUsers(mapBy(user.entities, 'id')))
|
||||
const entityUsers = await getEntityUsers(id);
|
||||
|
||||
const usersWithRole = entityUsers.map((u) => {
|
||||
@@ -68,7 +68,7 @@ export const getServerSideProps = withIronSessionSsr(async ({req, params}) => {
|
||||
user,
|
||||
entity,
|
||||
users: usersWithRole,
|
||||
linkedUsers: linkedUsers.users,
|
||||
linkedUsers: linkedUsers.filter(x => x.id !== user.id && !mapBy(entityUsers, 'id').includes(x.id)),
|
||||
}),
|
||||
};
|
||||
}, sessionOptions);
|
||||
|
||||
Reference in New Issue
Block a user