mirror of
https://github.com/cheveguerra/whaticket-community.git
synced 2026-04-19 20:29:17 +00:00
fix: use loggein user to handle userModal permissions
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
import React, { useState, useEffect } from "react";
|
import React, { useState, useEffect, useContext } from "react";
|
||||||
|
|
||||||
import * as Yup from "yup";
|
import * as Yup from "yup";
|
||||||
import { Formik, Form, Field } from "formik";
|
import { Formik, Form, Field } from "formik";
|
||||||
@@ -23,6 +23,7 @@ import { i18n } from "../../translate/i18n";
|
|||||||
import api from "../../services/api";
|
import api from "../../services/api";
|
||||||
import toastError from "../../errors/toastError";
|
import toastError from "../../errors/toastError";
|
||||||
import QueueSelect from "../QueueSelect";
|
import QueueSelect from "../QueueSelect";
|
||||||
|
import { AuthContext } from "../../context/Auth/AuthContext";
|
||||||
import { Can } from "../Can";
|
import { Can } from "../Can";
|
||||||
|
|
||||||
const useStyles = makeStyles(theme => ({
|
const useStyles = makeStyles(theme => ({
|
||||||
@@ -74,6 +75,8 @@ const UserModal = ({ open, onClose, userId }) => {
|
|||||||
profile: "user",
|
profile: "user",
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const { user: loggedInUser } = useContext(AuthContext);
|
||||||
|
|
||||||
const [user, setUser] = useState(initialState);
|
const [user, setUser] = useState(initialState);
|
||||||
const [selectedQueueIds, setSelectedQueueIds] = useState([]);
|
const [selectedQueueIds, setSelectedQueueIds] = useState([]);
|
||||||
|
|
||||||
@@ -184,7 +187,7 @@ const UserModal = ({ open, onClose, userId }) => {
|
|||||||
margin="dense"
|
margin="dense"
|
||||||
>
|
>
|
||||||
<Can
|
<Can
|
||||||
role={user.profile}
|
role={loggedInUser.profile}
|
||||||
perform="user-modal:editProfile"
|
perform="user-modal:editProfile"
|
||||||
yes={() => (
|
yes={() => (
|
||||||
<>
|
<>
|
||||||
@@ -209,7 +212,7 @@ const UserModal = ({ open, onClose, userId }) => {
|
|||||||
</FormControl>
|
</FormControl>
|
||||||
</div>
|
</div>
|
||||||
<Can
|
<Can
|
||||||
role={user.profile}
|
role={loggedInUser.profile}
|
||||||
perform="user-modal:editQueues"
|
perform="user-modal:editQueues"
|
||||||
yes={() => (
|
yes={() => (
|
||||||
<QueueSelect
|
<QueueSelect
|
||||||
|
|||||||
Reference in New Issue
Block a user