Criação de nova rule para que somente o administrador acesse o dashboard

pull/1/head
adriano 2022-01-10 17:35:45 -03:00
parent d687d0900a
commit 790b2c11a9
3 changed files with 64 additions and 152 deletions

View File

@ -413,113 +413,8 @@ const Connections = () => {
</Paper> </Paper>
</MainContainer> </MainContainer>
)} )}
/> />
/*<MainContainer>
<ConfirmationModal
title={confirmModalInfo.title}
open={confirmModalOpen}
onClose={setConfirmModalOpen}
onConfirm={handleSubmitConfirmationModal}
>
{confirmModalInfo.message}
</ConfirmationModal>
<QrcodeModal
open={qrModalOpen}
onClose={handleCloseQrModal}
whatsAppId={!whatsAppModalOpen && selectedWhatsApp?.id}
/>
<WhatsAppModal
open={whatsAppModalOpen}
onClose={handleCloseWhatsAppModal}
whatsAppId={!qrModalOpen && selectedWhatsApp?.id}
/>
<MainHeader>
<Title>{i18n.t("connections.title")}</Title>
<MainHeaderButtonsWrapper>
<Button
variant="contained"
color="primary"
onClick={handleOpenWhatsAppModal}
>
{i18n.t("connections.buttons.add")}
</Button>
</MainHeaderButtonsWrapper>
</MainHeader>
<Paper className={classes.mainPaper} variant="outlined">
<Table size="small">
<TableHead>
<TableRow>
<TableCell align="center">
{i18n.t("connections.table.name")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.status")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.session")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.lastUpdate")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.default")}
</TableCell>
<TableCell align="center">
{i18n.t("connections.table.actions")}
</TableCell>
</TableRow>
</TableHead>
<TableBody>
{loading ? (
<TableRowSkeleton />
) : (
<>
{whatsApps?.length > 0 &&
whatsApps.map(whatsApp => (
<TableRow key={whatsApp.id}>
<TableCell align="center">{whatsApp.name}</TableCell>
<TableCell align="center">
{renderStatusToolTips(whatsApp)}
</TableCell>
<TableCell align="center">
{renderActionButtons(whatsApp)}
</TableCell>
<TableCell align="center">
{format(parseISO(whatsApp.updatedAt), "dd/MM/yy HH:mm")}
</TableCell>
<TableCell align="center">
{whatsApp.isDefault && (
<div className={classes.customTableCell}>
<CheckCircle style={{ color: green[500] }} />
</div>
)}
</TableCell>
<TableCell align="center">
<IconButton
size="small"
onClick={() => handleEditWhatsApp(whatsApp)}
>
<Edit />
</IconButton>
<IconButton
size="small"
onClick={e => {
handleOpenConfirmationModal("delete", whatsApp.id);
}}
>
<DeleteOutline />
</IconButton>
</TableCell>
</TableRow>
))}
</>
)}
</TableBody>
</Table>
</Paper>
</MainContainer>*/
); );
}; };

View File

@ -14,6 +14,8 @@ import { i18n } from "../../translate/i18n";
import Chart from "./Chart" import Chart from "./Chart"
import { Can } from "../../components/Can";
const useStyles = makeStyles(theme => ({ const useStyles = makeStyles(theme => ({
container: { container: {
paddingTop: theme.spacing(4), paddingTop: theme.spacing(4),
@ -63,54 +65,68 @@ const Dashboard = () => {
return tickets.length; return tickets.length;
} }
return ( return (
<div>
<Container maxWidth="lg" className={classes.container}> <Can
<Grid container spacing={3}> role={user.profile}
<Grid item xs={4}> perform="dashboard-view:show"
<Paper className={classes.customFixedHeightPaper} style={{ overflow: "hidden" }}> yes={() => (
<Typography component="h3" variant="h6" color="primary" paragraph> <div>
{i18n.t("dashboard.messages.inAttendance.title")} <Container maxWidth="lg" className={classes.container}>
</Typography> <Grid container spacing={3}>
<Grid item> <Grid item xs={4}>
<Typography component="h1" variant="h4"> <Paper className={classes.customFixedHeightPaper} style={{ overflow: "hidden" }}>
{GetTickets("open", "true", "false")} <Typography component="h3" variant="h6" color="primary" paragraph>
</Typography> {i18n.t("dashboard.messages.inAttendance.title")}
</Typography>
<Grid item>
<Typography component="h1" variant="h4">
{GetTickets("open", "true", "false")}
</Typography>
</Grid>
</Paper>
</Grid> </Grid>
</Paper> <Grid item xs={4}>
</Grid> <Paper className={classes.customFixedHeightPaper} style={{ overflow: "hidden" }}>
<Grid item xs={4}> <Typography component="h3" variant="h6" color="primary" paragraph>
<Paper className={classes.customFixedHeightPaper} style={{ overflow: "hidden" }}> {i18n.t("dashboard.messages.waiting.title")}
<Typography component="h3" variant="h6" color="primary" paragraph> </Typography>
{i18n.t("dashboard.messages.waiting.title")} <Grid item>
</Typography> <Typography component="h1" variant="h4">
<Grid item> {GetTickets("pending", "true", "false")}
<Typography component="h1" variant="h4"> </Typography>
{GetTickets("pending", "true", "false")} </Grid>
</Typography> </Paper>
</Grid> </Grid>
</Paper> <Grid item xs={4}>
</Grid> <Paper className={classes.customFixedHeightPaper} style={{ overflow: "hidden" }}>
<Grid item xs={4}> <Typography component="h3" variant="h6" color="primary" paragraph>
<Paper className={classes.customFixedHeightPaper} style={{ overflow: "hidden" }}> {i18n.t("dashboard.messages.closed.title")}
<Typography component="h3" variant="h6" color="primary" paragraph> </Typography>
{i18n.t("dashboard.messages.closed.title")} <Grid item>
</Typography> <Typography component="h1" variant="h4">
<Grid item> {GetTickets("closed", "true", "false")}
<Typography component="h1" variant="h4"> </Typography>
{GetTickets("closed", "true", "false")} </Grid>
</Typography> </Paper>
</Grid> </Grid>
</Paper> <Grid item xs={12}>
</Grid> <Paper className={classes.fixedHeightPaper}>
<Grid item xs={12}> <Chart />
<Paper className={classes.fixedHeightPaper}> </Paper>
<Chart /> </Grid>
</Paper> </Grid>
</Grid> </Container>
</Grid> </div>
</Container> )}
</div> />
/**/
) )
} }

View File

@ -13,6 +13,7 @@ const rules = {
"contacts-page:deleteContact", "contacts-page:deleteContact",
"connections-view:show", "connections-view:show",
"dashboard-view:show",
], ],
}, },
}; };