From f0f49668fff059e1a86c07041ccf0699b054c448 Mon Sep 17 00:00:00 2001 From: adriano Date: Tue, 20 Jun 2023 09:17:30 -0300 Subject: [PATCH] =?UTF-8?q?Corre=C3=A7=C3=A3o=20do=20bug=20de=20frontend?= =?UTF-8?q?=20quando=20o=20usuario=20busca=20pela=20url=20um=20ticked=20id?= =?UTF-8?q?=20que=20n=C3=A3o=20existe?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/components/TicketActionButtons/index.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/TicketActionButtons/index.js b/frontend/src/components/TicketActionButtons/index.js index 8f69d43..c066113 100644 --- a/frontend/src/components/TicketActionButtons/index.js +++ b/frontend/src/components/TicketActionButtons/index.js @@ -31,11 +31,22 @@ const useStyles = makeStyles(theme => ({ const TicketActionButtons = ({ ticket, statusChatEnd }) => { const classes = useStyles(); - const history = useHistory(); + const history = useHistory(); const [anchorEl, setAnchorEl] = useState(null); const [loading, setLoading] = useState(false); - const [useDialogflow, setUseDialogflow] = useState(ticket.contact.useDialogflow); + + // const [useDialogflow, setUseDialogflow] = useState(ticket.contact.useDialogflow); + + const [useDialogflow, setUseDialogflow] = useState(() => { + if (Object.keys(ticket).length != 0) { + return ticket.contact.useDialogflow; + } else { + // Set a default value if `ticket.contact.useDialogflow` is null + return true + } + }); + const ticketOptionsMenuOpen = Boolean(anchorEl); const { user } = useContext(AuthContext);