diff --git a/frontend/src/pages/Users/index.js b/frontend/src/pages/Users/index.js index f876d34..783cd55 100644 --- a/frontend/src/pages/Users/index.js +++ b/frontend/src/pages/Users/index.js @@ -1,4 +1,4 @@ -import React, { useState, useEffect, useReducer } from "react"; +import React, { useState, useEffect, useReducer, useContext} from "react"; import { toast } from "react-toastify"; import openSocket from "socket.io-client"; @@ -30,6 +30,10 @@ import UserModal from "../../components/UserModal"; import ConfirmationModal from "../../components/ConfirmationModal"; import toastError from "../../errors/toastError"; +//-------- +import { AuthContext } from "../../context/Auth/AuthContext"; +import { Can } from "../../components/Can"; + const reducer = (state, action) => { if (action.type === "LOAD_USERS") { const users = action.payload; @@ -85,6 +89,9 @@ const useStyles = makeStyles((theme) => ({ const Users = () => { const classes = useStyles(); + + //-------- + const { user: userA } = useContext(AuthContext); const [loading, setLoading] = useState(false); const [pageNumber, setPageNumber] = useState(1); @@ -183,112 +190,121 @@ const Users = () => { }; return ( - - handleDeleteUser(deletingUser.id)} - > - {i18n.t("users.confirmationModal.deleteMessage")} - - - - {i18n.t("users.title")} - - - - - ), - }} - /> - - - - - - - - - {i18n.t("users.table.name")} - - {i18n.t("users.table.email")} - - - {i18n.t("users.table.profile")} - - - - {i18n.t("users.table.actions")} - - - - - - <> - {users.map((user) => ( - - {user.name} - {user.email} - {user.profile} - - + ( + + handleDeleteUser(deletingUser.id)} + > + {i18n.t("users.confirmationModal.deleteMessage")} + + + + {i18n.t("users.title")} + + + + + ), + }} + /> + + + + + + +
+ + + {i18n.t("users.table.name")} + + {i18n.t("users.table.email")} + + + {i18n.t("users.table.profile")} + + + + {i18n.t("users.table.actions")} + + + + + + <> + {users.map((user) => ( + + {user.name} + {user.email} + {user.profile} - handleEditUser(user)} - > - - + + + handleEditUser(user)} + > + + + + { + setConfirmModalOpen(true); + setDeletingUser(user); + }} + > + + + + + + + ))} + {loading && } + + +
+
+
+ )} + /> - { - setConfirmModalOpen(true); - setDeletingUser(user); - }} - > - - - - - - - ))} - {loading && } - - - - - + ); }; diff --git a/frontend/src/rules.js b/frontend/src/rules.js index 20fa351..38ce041 100644 --- a/frontend/src/rules.js +++ b/frontend/src/rules.js @@ -15,6 +15,7 @@ const rules = { "connections-view:show", "dashboard-view:show", "queues-view:show", + "user-view:show", ], }, };