|
|
|
@ -1,3 +1,12 @@
|
|
|
|
|
const phoneMask = (value) => { |
|
|
|
|
if (!value) return "" |
|
|
|
|
value = value.replace(/\D/g,'') |
|
|
|
|
value = value.replace(/(\d{2})(\d)/,"+$1 $2") |
|
|
|
|
value = value.replace(/(\d{2})(\d)/,"($1) $2") |
|
|
|
|
value = value.replace(/(\d)(\d{4})$/,"$1-$2") |
|
|
|
|
return value |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** ROLAGEM DO SCROLL AT<EFBFBD> NO FINAL DO CHAT */ |
|
|
|
|
const scrollDown = () => { |
|
|
|
|
$(".chat-window").animate({ scrollTop: 99999 * $(this).height() }, 1); |
|
|
|
@ -16,21 +25,20 @@ function formatedNumber(telefone) {
|
|
|
|
|
} |
|
|
|
|
const search = (input) => { |
|
|
|
|
let inputValue = input.value.trim(); |
|
|
|
|
$("#chats").empty(); |
|
|
|
|
const atendimentos = JSON.parse(localStorage.getItem('obj_search')).data; |
|
|
|
|
let pesquisa; |
|
|
|
|
let chatList = ""; |
|
|
|
|
|
|
|
|
|
if (!inputValue) { |
|
|
|
|
notifications(); |
|
|
|
|
return; |
|
|
|
|
return isAtend ? notifications() : filaNotifications();; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$("#chats").empty(); |
|
|
|
|
const key = isAtend ? 'obj_search' : 'obj_queueNotification'; |
|
|
|
|
const atendimentos = JSON.parse(localStorage.getItem(key)); |
|
|
|
|
let pesquisa; |
|
|
|
|
let chatList = ""; |
|
|
|
|
pesquisa = atendimentos.filter((atendimento) => { |
|
|
|
|
return ( |
|
|
|
|
atendimento.nome.toLowerCase().includes(inputValue.toLowerCase()) || |
|
|
|
|
atendimento.protocolo.toString().includes(inputValue.toLowerCase()) || |
|
|
|
|
atendimento.cliente_id.toString().includes(inputValue.toLowerCase()) |
|
|
|
|
atendimento?.nome.toLowerCase().includes(inputValue.toLowerCase()) || |
|
|
|
|
atendimento?.protocolo.toString().includes(inputValue.toLowerCase()) || |
|
|
|
|
atendimento?.cliente_id.toString().includes(inputValue.toLowerCase()) |
|
|
|
|
) |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -50,7 +58,8 @@ const search = (input) => {
|
|
|
|
|
status: e.status, |
|
|
|
|
protocolo: e.protocolo, |
|
|
|
|
media: e.media, |
|
|
|
|
evento: e.evento |
|
|
|
|
evento: e.evento, |
|
|
|
|
type: chatTypes.search |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
@ -377,11 +386,10 @@ const enviaHsm = async (btn) => {
|
|
|
|
|
toggleEnvioTemplates(false); |
|
|
|
|
abrirTelaContato(); |
|
|
|
|
const atendimento = response.data.data; |
|
|
|
|
startSearch(); |
|
|
|
|
notifications(); |
|
|
|
|
loadingBtn(btn, "Enviar Mensagem", false) |
|
|
|
|
setTimeout(() => { |
|
|
|
|
selectNotification(atendimento.uniqueid, true, atendimento.data_reg); |
|
|
|
|
selectNotification(atendimento.uniqueid, true, atendimento.data_reg, chatTypes.notification); |
|
|
|
|
}, 1000); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -397,13 +405,29 @@ const cadastroContato = async (form) => {
|
|
|
|
|
descricao: formData.get("descricao"), |
|
|
|
|
status: formData.get("ativo") |
|
|
|
|
}; |
|
|
|
|
const response = await cadastrarContato(dataSend); |
|
|
|
|
|
|
|
|
|
if (response) { |
|
|
|
|
alert('Cadastrado com sucesso'); |
|
|
|
|
voltarTelaCadastro(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* Gerencia a renderização do chat |
|
|
|
|
*/ |
|
|
|
|
const typeChat = (type) => { |
|
|
|
|
let data; |
|
|
|
|
switch (type) { |
|
|
|
|
case 1: |
|
|
|
|
data = JSON.parse(localStorage.getItem("obj_search")) |
|
|
|
|
break; |
|
|
|
|
case 2: |
|
|
|
|
data = JSON.parse(localStorage.getItem("obj_notification")).data |
|
|
|
|
break; |
|
|
|
|
default: |
|
|
|
|
break; |
|
|
|
|
} |
|
|
|
|
return data; |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* GERENCIA A RESPONSIVIDADE DO LAYOUT |
|
|
|
|
*/ |
|
|
|
@ -889,7 +913,7 @@ const buildNotification = (data = {}) => {
|
|
|
|
|
const badge = data.evento === sendTemplate ? "<i class='fas fa-share'></i>" : "<i class='fas fa-reply'></i>" |
|
|
|
|
const datesend = converdata(data.datetime); |
|
|
|
|
const status = (data.status == 0) ? "opacity-8" : ""; |
|
|
|
|
return `<div class="chat ${status}" id="${data.uniqueid}" onclick="selectNotification(this.id, ${data.status}, '${data.datetime}')">
|
|
|
|
|
return `<div class="chat ${status}" id="${data.uniqueid}" onclick="selectNotification(this.id, ${data.status}, '${data.datetime}', ${data.type})">
|
|
|
|
|
<div class="chat-left"> |
|
|
|
|
<img src="${path}/images/${data.media}.png"/> |
|
|
|
|
</div> |
|
|
|
@ -991,7 +1015,7 @@ const startSearch = () => {
|
|
|
|
|
localStorage.getItem("my_uniqueid") |
|
|
|
|
).then(res => { |
|
|
|
|
localStorage.removeItem('obj_search'); |
|
|
|
|
localStorage.setItem('obj_search', JSON.stringify(res)); |
|
|
|
|
localStorage.setItem('obj_search', JSON.stringify(res.data)); |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
@ -1046,12 +1070,11 @@ const notifications = (obj = {}) => {
|
|
|
|
|
status: e.status, |
|
|
|
|
protocolo: e.protocolo, |
|
|
|
|
media: e.media, |
|
|
|
|
evento: e.evento |
|
|
|
|
evento: e.evento, |
|
|
|
|
type: chatTypes.notification |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
chatsArray = chat; |
|
|
|
|
click_btn(document.querySelector("#btnAtendimento")); |
|
|
|
|
$("#chats").append(chatList); |
|
|
|
|
}); |
|
|
|
|
}; |
|
|
|
@ -1092,9 +1115,7 @@ const filaNotifications = (obj = {}) => {
|
|
|
|
|
media: e.media, |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
chatsArray = chat; |
|
|
|
|
|
|
|
|
|
localStorage.setItem('obj_queueNotification', JSON.stringify(chat)); |
|
|
|
|
$("#chats").append(chatList); |
|
|
|
|
} |
|
|
|
|
); |
|
|
|
@ -1158,12 +1179,10 @@ const supervisorAgente = () => {
|
|
|
|
|
window.close(); |
|
|
|
|
} |
|
|
|
|
startSearch(); |
|
|
|
|
notifications(); |
|
|
|
|
}); |
|
|
|
|
}, 30000); |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** CONNECT TO WS */ |
|
|
|
|
const connect = (wsserver) => { |
|
|
|
|
const ws = new WebSocket(wsserver); |
|
|
|
|