fix: update socket to enable click button on remote ticket

feat-scaling-ticket-remote-creation
adriano 2024-04-23 22:02:17 -03:00
parent b54580fdf9
commit beb4fd64c4
2 changed files with 32 additions and 11 deletions

View File

@ -124,12 +124,7 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
useEffect(() => {
setRemoteTicketsControll(remoteTicketsControll)
}, [remoteTicketsControll])
useEffect(() => {
setRemoteTicketsControll(remoteTicketsControll)
}, [settings])
}, [remoteTicketsControll, settings])
const handleAcepptTicket = async id => {
setLoading(true)
@ -154,6 +149,35 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
history.push(`/tickets/${id}`)
}
useEffect(() => {
const socket = openSocket(process.env.REACT_APP_BACKEND_URL)
socket.on('remoteTickesControll', (data) => {
console.log('REMOTE TICKETS CONTROLL UPDATE2: ', data.tickets)
if (data.action === 'update') {
setRemoteTicketsControll(data.tickets)
}
})
socket.on('settings', (data) => {
if (data.action === 'update') {
setSettings((prevState) => {
const aux = [...prevState]
const settingIndex = aux.findIndex((s) => s.key === data.setting.key)
aux[settingIndex].value = data.setting.value
return aux
})
}
})
return () => {
socket.disconnect()
}
}, [])
return (
<React.Fragment key={ticket.id}>
<Tooltip
@ -161,7 +185,7 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
placement="right"
title={
(ticket?.isRemote && ticket?.remoteDone && ticket.status === 'pending') ? "Mensagem de campanha enviada" : (ticket?.isRemote && ticket.status === 'pending') ? "Mensagem de campanha ainda não enviada" :
""
""
}
>
@ -288,9 +312,6 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
getSettingValue('remoteTicketSendControll') &&
getSettingValue('remoteTicketSendControll') === 'enabled') && ticket?.isRemote && !ticket?.remoteDone && !_remoteTicketsControll?.includes(+ticket.id)) : false}
// disabled={true ? (ticket?.isRemote && !ticket?.remoteDone && !_remoteTicketsControll?.includes(+ticket.id)) : false}
className={classes.acceptButton}
size="small"
loading={loading}

View File

@ -317,7 +317,7 @@ const TicketsList = (props) => {
socket.on('remoteTickesControll', (data) => {
console.log('REMOTE TICKETS CONTROLL UPDATE 1: ', data.tickets)
if (data.action === 'update') {
setRemoteTicketsControll(data.tickets)
}