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(() => { useEffect(() => {
setRemoteTicketsControll(remoteTicketsControll) setRemoteTicketsControll(remoteTicketsControll)
}, [remoteTicketsControll]) }, [remoteTicketsControll, settings])
useEffect(() => {
setRemoteTicketsControll(remoteTicketsControll)
}, [settings])
const handleAcepptTicket = async id => { const handleAcepptTicket = async id => {
setLoading(true) setLoading(true)
@ -154,6 +149,35 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
history.push(`/tickets/${id}`) 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 ( return (
<React.Fragment key={ticket.id}> <React.Fragment key={ticket.id}>
<Tooltip <Tooltip
@ -288,9 +312,6 @@ const TicketListItem = ({ ticket, remoteTicketsControll, settings }) => {
getSettingValue('remoteTicketSendControll') && getSettingValue('remoteTicketSendControll') &&
getSettingValue('remoteTicketSendControll') === 'enabled') && ticket?.isRemote && !ticket?.remoteDone && !_remoteTicketsControll?.includes(+ticket.id)) : false} 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} className={classes.acceptButton}
size="small" size="small"
loading={loading} loading={loading}

View File

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