|
|
|
@ -4,12 +4,10 @@ const scrollDown = () => {
|
|
|
|
|
}; |
|
|
|
|
const responsivoButtonsHeader = () => { |
|
|
|
|
let chat_windown = document.querySelector(".chat-window-header-right"); |
|
|
|
|
|
|
|
|
|
chat_windown.classList.toggle("ativo"); |
|
|
|
|
}; |
|
|
|
|
function formatedNumber(telefone) { |
|
|
|
|
const numeros = telefone.replace(/\D/g, ''); |
|
|
|
|
|
|
|
|
|
if (numeros.length < 10) { |
|
|
|
|
return telefone; |
|
|
|
|
} |
|
|
|
@ -19,18 +17,35 @@ function formatedNumber(telefone) {
|
|
|
|
|
const search = (input) => { |
|
|
|
|
let inputValue = input.value.trim(); |
|
|
|
|
$("#chats").empty(); |
|
|
|
|
let pesquisa = chatsArray.filter((item) => |
|
|
|
|
item.nome.toLowerCase().includes(inputValue.toLowerCase()) |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
const atendimentos = JSON.parse(localStorage.getItem('obj_search')).data; |
|
|
|
|
let pesquisa; |
|
|
|
|
let chatList = ""; |
|
|
|
|
pesquisa.sort((a, b) => b.status - a.status); |
|
|
|
|
pesquisa.forEach((e) => { |
|
|
|
|
|
|
|
|
|
if (!inputValue) { |
|
|
|
|
notifications(); |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pesquisa = atendimentos.filter((atendimento) => { |
|
|
|
|
return ( |
|
|
|
|
atendimento.nome.toLowerCase().includes(inputValue.toLowerCase()) || |
|
|
|
|
atendimento.protocolo.toString().includes(inputValue.toLowerCase()) || |
|
|
|
|
atendimento.cliente_id.toString().includes(inputValue.toLowerCase()) |
|
|
|
|
) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
let chat = pesquisa.filter(function (a) { |
|
|
|
|
return ( |
|
|
|
|
!this[JSON.stringify(a.uniqueid)] && (this[JSON.stringify(a.uniqueid)] = true) |
|
|
|
|
); |
|
|
|
|
}, Object.create(null)); |
|
|
|
|
chat.sort((a, b) => b.status - a.status); |
|
|
|
|
chat.forEach((e) => { |
|
|
|
|
chatList += buildNotification({ |
|
|
|
|
uniqueid: e.uniqueid, |
|
|
|
|
number: e.cliente_id, |
|
|
|
|
media: e.context, |
|
|
|
|
name: e.nome, |
|
|
|
|
name: e.profile_name, |
|
|
|
|
datetime: e.data_reg, |
|
|
|
|
status: e.status, |
|
|
|
|
protocolo: e.protocolo, |
|
|
|
@ -431,9 +446,6 @@ const monitoraStatusRecuperacaoAtendimento = (date) => {
|
|
|
|
|
const start = new Date(formatedTransferDate); |
|
|
|
|
const end = new Date(formatedDate); |
|
|
|
|
const diffInTime = Math.abs(end - start) / 1000 / 60 / 60 |
|
|
|
|
console.log(start); |
|
|
|
|
console.log(end); |
|
|
|
|
console.log(diffInTime); |
|
|
|
|
if (diffInTime > RecuperacaoAtendimentoLimite) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
@ -967,6 +979,20 @@ const notifyMe = (title, content) => {
|
|
|
|
|
}); |
|
|
|
|
} |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
const startSearch = () => { |
|
|
|
|
let matricula = localStorage.getItem("token") |
|
|
|
|
if (typeof matricula == "undefined") { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
listarTodosAtendimentoAgente( |
|
|
|
|
localStorage.getItem("my_uniqueid") |
|
|
|
|
).then(res => { |
|
|
|
|
localStorage.removeItem('obj_search'); |
|
|
|
|
localStorage.setItem('obj_search', JSON.stringify(res)); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* CRIA AS NOTIFICACOES DE TODOS OS ATENDIMENTOS NA INICIALIZACAO DO SISTEMA OU ATUALIZACAO |
|
|
|
|
*/ |
|
|
|
@ -1029,7 +1055,6 @@ const notifications = (obj = {}) => {
|
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* CRIA AS NOTIFICACOES DE TODOS OS ATENDIMENTOS QUE ESTÃO NA FILA |
|
|
|
|
*/ |
|
|
|
@ -1131,6 +1156,7 @@ const supervisorAgente = () => {
|
|
|
|
|
if (agente.status == "error" && agente.message == "Agente não encontrado") { |
|
|
|
|
window.close(); |
|
|
|
|
} |
|
|
|
|
startSearch(); |
|
|
|
|
}); |
|
|
|
|
}, 30000); |
|
|
|
|
}; |
|
|
|
@ -1211,7 +1237,6 @@ const connect = (wsserver) => {
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** RECEBE AS NOTIFICAÇÕES E RENDERIZA NA TELA)*/ |
|
|
|
|
// console.log(data);
|
|
|
|
|
if (data.event?.mensagem.type === 'alert') { |
|
|
|
|
renderNotification(data); |
|
|
|
|
} |
|
|
|
|