Skip to content

Commit

Permalink
Habilitar/Desabilitar botão Mover para Aguardando
Browse files Browse the repository at this point in the history
  • Loading branch information
rtenorioh committed Feb 10, 2025
1 parent c322a1a commit 681cbe0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 3 deletions.
26 changes: 24 additions & 2 deletions frontend/src/components/TicketListItem/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,7 @@ const TicketListItem = ({ ticket, filteredTags }) => {
const [acceptTicketWithouSelectQueueOpen, setAcceptTicketWithouSelectQueueOpen] = useState(false);
const [confirmationOpen, setConfirmationOpen] = useState(false);
const [tag, setTag] = useState([]);
const [settings, setSettings] = useState([]);

useEffect(() => {
isMounted.current = true;
Expand Down Expand Up @@ -226,6 +227,20 @@ const TicketListItem = ({ ticket, filteredTags }) => {
};
}, []);

useEffect(() => {
const fetchSettings = async () => {
try {
const { data } = await api.get("/settings");
setSettings(data);
} catch (err) {
console.error(err);
toastError(err);
setSettings([]);
}
};
fetchSettings();
}, []);

const filterTicketByTags = () => {
if (!filteredTags || filteredTags.length === 0) return true;
if (!tag || tag.length === 0) return false;
Expand Down Expand Up @@ -338,6 +353,13 @@ const TicketListItem = ({ ticket, filteredTags }) => {
handleClosedTicket(ticket.id);
};

const canTabsSettings = (ts) => {
return (
(settings && settings.some(s => s.key === ts && s.value === "enabled")) ||
(user && user.profile === "admin")
);
};

return (
<React.Fragment key={ticket.id}>
<AcceptTicketWithouSelectQueue
Expand Down Expand Up @@ -605,9 +627,9 @@ const TicketListItem = ({ ticket, filteredTags }) => {
<ClearOutlined />
</IconButton>
</Tooltip>
)}
)}

{ticket.status === "open" && (
{canTabsSettings("tabsPending") && ticket.status === "open" && (
<Tooltip title={t("ticketsList.items.return")}>
<IconButton
className={classes.bottomButton}
Expand Down
1 change: 0 additions & 1 deletion frontend/src/translate/languages/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,6 @@ const messages = {
options: {
enabled: "Enabled",
disabled: "Disabled",
disabled: "Desativado",
},
},
timeCreateNewTicket: {
Expand Down

0 comments on commit 681cbe0

Please sign in to comment.