|
|
@@ -139,11 +139,21 @@ function formatPrevia(conversa) {
|
|
|
return conversa.NomeContato || conversa.Telefone;
|
|
|
}
|
|
|
|
|
|
+function mensagemErroEnvio(err) {
|
|
|
+ if (err?.message === "whatsapp_nao_conectado") return "WhatsApp desconectado. Peça a um admin para reconectar.";
|
|
|
+ return `Erro ao enviar: ${err?.message ?? "erro desconhecido"}`;
|
|
|
+}
|
|
|
+
|
|
|
async function enviar() {
|
|
|
if (!texto.value.trim() || enviando.value) return;
|
|
|
const valor = texto.value;
|
|
|
texto.value = "";
|
|
|
- await enviarResposta(valor);
|
|
|
+ try {
|
|
|
+ await enviarResposta(valor);
|
|
|
+ } catch (err) {
|
|
|
+ texto.value = valor;
|
|
|
+ toast.erro(mensagemErroEnvio(err));
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
let refreshTimer = null;
|