From a4c316c3cebdc480d67393d4c7e950600a543bd9 Mon Sep 17 00:00:00 2001 From: Maxime Lalo Date: Mon, 9 Oct 2023 11:08:18 +0200 Subject: [PATCH] :sparkles: Super admin can manage office roles --- .../Layouts/Users/UserInformations/index.tsx | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/front/Components/Layouts/Users/UserInformations/index.tsx b/src/front/Components/Layouts/Users/UserInformations/index.tsx index c31d7404..b6c87a5d 100644 --- a/src/front/Components/Layouts/Users/UserInformations/index.tsx +++ b/src/front/Components/Layouts/Users/UserInformations/index.tsx @@ -18,6 +18,7 @@ import { useRouter } from "next/router"; import { useCallback, useEffect, useState } from "react"; import classes from "./classes.module.scss"; +import OfficeRoles from "@Front/Api/LeCoffreApi/Admin/OfficeRoles/OfficeRoles"; type IProps = {}; export default function UserInformations(props: IProps) { @@ -68,11 +69,15 @@ export default function UserInformations(props: IProps) { }, }); if (!user) return; - const roles = await Roles.getInstance().get({ - where: { NOT: { OR: [{ name: "super-admin" }, { name: "admin" }] } }, + console.log("User to edit : ", user); + const roles = await OfficeRoles.getInstance().get({ + where: { + office: { uid: user.office_membership?.uid }, + NOT: { OR: [{ name: "super-admin" }, { name: "admin" }] }, + }, }); if (!roles) return; - setAvailableRoles(roles.map((role) => ({ value: role.uid, label: role.label }))); + setAvailableRoles(roles.map((role) => ({ value: role.uid, label: role.name }))); setUserSelected(user); }, [userUid]);