diff --git a/client/src/Pages/Account/EditUser/index.tsx b/client/src/Pages/Account/EditUser/index.tsx index b596bcd32..5a10898f6 100644 --- a/client/src/Pages/Account/EditUser/index.tsx +++ b/client/src/Pages/Account/EditUser/index.tsx @@ -1,10 +1,16 @@ -import { Stack, MenuItem } from "@mui/material"; +import { Stack, Typography, IconButton, Divider } from "@mui/material"; import { useTheme } from "@mui/material"; import { useTranslation } from "react-i18next"; import { ConfigBox, BasePage, Breadcrumb } from "@/Components/v2/design-elements"; -import { TextField, Button, Select } from "@/Components/v2/inputs"; +import { TextField, Button, Autocomplete } from "@/Components/v2/inputs"; import { UserRoles } from "@/Types/User"; import { useState } from "react"; +import { Trash2 } from "lucide-react"; + +interface RoleOption { + id: string; + name: string; +} const EditUserPage = () => { const theme = useTheme(); @@ -17,6 +23,17 @@ const EditUserPage = () => { const editableRoles = UserRoles.filter((role) => role !== "superadmin"); + const roleOptions: RoleOption[] = editableRoles.map((role) => ({ + id: role, + name: t(`common.auth.roles.${role}`), + })); + + const selectedRoles = roleOptions.filter((r) => roles.includes(r.id)); + + const handleRemoveRole = (roleToRemove: string) => { + setRoles(roles.filter((role) => role !== roleToRemove)); + }; + return ( @@ -50,25 +67,47 @@ const EditUserPage = () => { } /> setRoles(e.target.value as string[])} - placeholder={t("pages.account.team.invite.role.placeholder")} - sx={{ minWidth: 200 }} - > - {editableRoles.map((role) => ( - + option.name} + onChange={(_: unknown, newValue: RoleOption[]) => { + setRoles(newValue.map((r) => r.id)); + }} + isOptionEqualToValue={(option, value) => option.id === value.id} + /> + {selectedRoles.length > 0 && ( + - {t(`common.auth.roles.${role}`)} - - ))} - + {selectedRoles.map((role, index) => ( + + {role.name} + handleRemoveRole(role.id)} + aria-label="Remove role" + > + + + {index < selectedRoles.length - 1 && } + + ))} + + )} + } />