Alteração na rule settings para que somente o administrador tenha acesso

pull/1/head
adriano 2022-01-10 20:43:32 -03:00
parent 78074b0d09
commit d5d9afe86b
1 changed files with 47 additions and 31 deletions

View File

@ -1,4 +1,4 @@
import React, { useState, useEffect } from "react"; import React, { useState, useEffect, useContext} from "react";
import openSocket from "socket.io-client"; import openSocket from "socket.io-client";
import { makeStyles } from "@material-ui/core/styles"; import { makeStyles } from "@material-ui/core/styles";
@ -12,6 +12,10 @@ import api from "../../services/api";
import { i18n } from "../../translate/i18n.js"; import { i18n } from "../../translate/i18n.js";
import toastError from "../../errors/toastError"; import toastError from "../../errors/toastError";
//--------
import { AuthContext } from "../../context/Auth/AuthContext";
import { Can } from "../../components/Can";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
root: { root: {
display: "flex", display: "flex",
@ -36,6 +40,9 @@ const useStyles = makeStyles(theme => ({
const Settings = () => { const Settings = () => {
const classes = useStyles(); const classes = useStyles();
//--------
const { user } = useContext(AuthContext);
const [settings, setSettings] = useState([]); const [settings, setSettings] = useState([]);
useEffect(() => { useEffect(() => {
@ -89,37 +96,46 @@ const Settings = () => {
}; };
return ( return (
<div className={classes.root}>
<Container className={classes.container} maxWidth="sm">
<Typography variant="body2" gutterBottom> <Can
{i18n.t("settings.title")} role={user.profile}
</Typography> perform="ticket-options:deleteTicket"
<Paper className={classes.paper}> yes={() => (
<Typography variant="body1"> <div className={classes.root}>
{i18n.t("settings.settings.userCreation.name")} <Container className={classes.container} maxWidth="sm">
<Typography variant="body2" gutterBottom>
{i18n.t("settings.title")}
</Typography> </Typography>
<Select <Paper className={classes.paper}>
margin="dense" <Typography variant="body1">
variant="outlined" {i18n.t("settings.settings.userCreation.name")}
native </Typography>
id="userCreation-setting" <Select
name="userCreation" margin="dense"
value={ variant="outlined"
settings && settings.length > 0 && getSettingValue("userCreation") native
} id="userCreation-setting"
className={classes.settingOption} name="userCreation"
onChange={handleChangeSetting} value={
> settings && settings.length > 0 && getSettingValue("userCreation")
<option value="enabled"> }
{i18n.t("settings.settings.userCreation.options.enabled")} className={classes.settingOption}
</option> onChange={handleChangeSetting}
<option value="disabled"> >
{i18n.t("settings.settings.userCreation.options.disabled")} <option value="enabled">
</option> {i18n.t("settings.settings.userCreation.options.enabled")}
</Select> </option>
</Paper> <option value="disabled">
</Container> {i18n.t("settings.settings.userCreation.options.disabled")}
</div> </option>
</Select>
</Paper>
</Container>
</div>
)}
/>
); );
}; };