Skip to content

Commit

Permalink
Botão aceitar apenas para Admin ao espiar
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Oct 12, 2022
1 parent 7e8436f commit 4989417
Showing 1 changed file with 23 additions and 14 deletions.
37 changes: 23 additions & 14 deletions frontend/src/components/TicketActionButtons/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import TicketOptionsMenu from "../TicketOptionsMenu";
import ButtonWithSpinner from "../ButtonWithSpinner";
import toastError from "../../errors/toastError";
import { AuthContext } from "../../context/Auth/AuthContext";
import { Can } from "../Can";

const useStyles = makeStyles(theme => ({
actionButtons: {
Expand Down Expand Up @@ -91,9 +92,9 @@ const TicketActionButtons = ({ ticket }) => {
>
{i18n.t("messagesList.header.buttons.resolve")}
</ButtonWithSpinner>
<IconButton
color="primary"
onClick={handleOpenTicketOptionsMenu}>
<IconButton
color="primary"
onClick={handleOpenTicketOptionsMenu}>
<MoreVert />
</IconButton>
<TicketOptionsMenu
Expand All @@ -104,17 +105,25 @@ const TicketActionButtons = ({ ticket }) => {
/>
</>
)}
{ticket.status === "pending" && (
<ButtonWithSpinner
loading={loading}
size="small"
variant="contained"
color="primary"
onClick={e => handleUpdateTicketStatus(e, "open", user?.id)}
>
{i18n.t("messagesList.header.buttons.accept")}
</ButtonWithSpinner>
)}
<Can
role={user.profile}
perform="drawer-admin-items:view"
yes={() => (
<>
{ticket.status === "pending" && (
<ButtonWithSpinner
loading={loading}
size="small"
variant="contained"
color="primary"
onClick={e => handleUpdateTicketStatus(e, "open", user?.id)}
>
{i18n.t("messagesList.header.buttons.accept")}
</ButtonWithSpinner>
)}
</>
)}
/>
</div>
);
};
Expand Down

0 comments on commit 4989417

Please sign in to comment.