diff --git a/public/js/main.js b/public/js/main.js index 249b045..11366c0 100644 --- a/public/js/main.js +++ b/public/js/main.js @@ -175,18 +175,17 @@ const selectNotification = (id) => { const datesend = e.msg_date ? converdata(new Date(e.msg_date).getTime()) : "algumas horas"; - let typesend = - atendimentos.data[0].cliente_id == e.dst ? "sender" : "receiver"; + + let typesend = atendimentos.data[0].cliente_id == e.src ? "receiver" : "sender"; + let statusMessage = e.status != 'error' ? datesend : 'Mensagem não foi enviada!'; + if (e.type == "text") { $(".chat-window").append(` -
- ${e.content.replace( - /\r?\n/g, - "
" - )}
-
- ${datesend} -
`); +
+ ${e.content.replace(/\r?\n/g,"
")}
+
+ ${statusMessage} +
`); } if (e.type == "transfer") { $(".chat-window").append(` @@ -274,6 +273,12 @@ const sendMessage = (obj = {}) => { const sendNumber = localStorage.getItem("session_window"); const myUniqueid = localStorage.getItem("my_uniqueid"); const agent = JSON.parse(localStorage.getItem("obj_status")); + + if(!sendNumber || !myUniqueid || !agent){ + alert('Não foi possível carregar todas as informações do sessão do atendimento! Por favor, Tente novamente.'); + return; + } + let sendContent = typeof obj.fileContent === "undefined" ? $("#fieldsendmessage").val()