From f60df038d82c1b9bb6a1b4b08a131aa17c6fa3e8 Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Fri, 3 Jul 2026 14:47:31 -0500 Subject: [PATCH] fix(chat): capture template name/lang before closing modal in sendTemplate closeTemplatePicker() sets _tplSelected = null, so accessing _tplSelected.template_name after the call threw a TypeError caught as "Error de red al enviar plantilla". Co-Authored-By: Claude Sonnet 4.6 --- modules/turnero/views/chat.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/turnero/views/chat.php b/modules/turnero/views/chat.php index bc75bbb..219a5d5 100644 --- a/modules/turnero/views/chat.php +++ b/modules/turnero/views/chat.php @@ -1002,7 +1002,10 @@ async function sendTemplate() { const missing = params.findIndex(p => !p); if (missing !== -1) { inputs[missing].focus(); return; } + const templateName = _tplSelected.template_name; + const templateLang = _tplSelected.language_code; closeTemplatePicker(); + try { const res = await fetch(BASE + API_SEND, { method: 'POST', @@ -1010,8 +1013,8 @@ async function sendTemplate() { body: JSON.stringify({ user_id: state.activeUserId, type: 'template', - template: _tplSelected.template_name, - lang: _tplSelected.language_code, + template: templateName, + lang: templateLang, params }) });