654 lines
19 KiB
HTML
654 lines
19 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8" />
|
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
|
|
<title>Collina — Nuevo acuerdo de confidencialidad</title>
|
|
<style>
|
|
:root {
|
|
--wk-azul: #1a56db;
|
|
--wk-azul-oscuro: #1e429f;
|
|
--wk-rojo: #b91c1c;
|
|
--wk-gris: #6b7280;
|
|
--wk-gris-claro: #e5e7eb;
|
|
--wk-gris-bg: #f9fafb;
|
|
--wk-negro: #111827;
|
|
}
|
|
|
|
* { box-sizing: border-box; }
|
|
|
|
html, body {
|
|
margin: 0;
|
|
padding: 0;
|
|
background: #fff;
|
|
color: var(--wk-negro);
|
|
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
|
|
"Helvetica Neue", Arial, sans-serif;
|
|
font-size: 16px;
|
|
line-height: 1.45;
|
|
}
|
|
|
|
.wrapper {
|
|
max-width: 680px;
|
|
margin: 0 auto;
|
|
padding: 20px 18px 80px;
|
|
}
|
|
|
|
header.top {
|
|
padding: 16px 0 24px;
|
|
border-bottom: 2px solid var(--wk-azul);
|
|
margin-bottom: 24px;
|
|
}
|
|
header.top h1 {
|
|
color: var(--wk-azul);
|
|
font-size: 1.4rem;
|
|
margin: 0 0 4px;
|
|
letter-spacing: -0.2px;
|
|
}
|
|
header.top p {
|
|
margin: 0;
|
|
color: var(--wk-gris);
|
|
font-size: 0.95rem;
|
|
}
|
|
|
|
section.bloque {
|
|
border: 1px solid var(--wk-gris-claro);
|
|
border-radius: 10px;
|
|
padding: 18px 16px;
|
|
margin-bottom: 20px;
|
|
background: #fff;
|
|
}
|
|
section.bloque h2 {
|
|
font-size: 1.05rem;
|
|
margin: 0 0 14px;
|
|
color: var(--wk-negro);
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 8px;
|
|
}
|
|
section.bloque h2 .tag {
|
|
background: var(--wk-azul);
|
|
color: #fff;
|
|
font-size: 0.7rem;
|
|
font-weight: 600;
|
|
padding: 2px 8px;
|
|
border-radius: 999px;
|
|
letter-spacing: 0.3px;
|
|
}
|
|
|
|
.row { display: flex; flex-wrap: wrap; gap: 12px; margin-bottom: 10px; }
|
|
.row > .field { flex: 1 1 100%; min-width: 0; }
|
|
.row.inline > .field { flex: 1 1 calc(50% - 6px); }
|
|
|
|
.field { display: flex; flex-direction: column; margin-bottom: 10px; }
|
|
.field label {
|
|
font-size: 0.85rem;
|
|
font-weight: 600;
|
|
color: var(--wk-negro);
|
|
margin-bottom: 4px;
|
|
}
|
|
.field label .req { color: var(--wk-rojo); margin-left: 2px; }
|
|
.field input, .field select, .field textarea {
|
|
padding: 10px 12px;
|
|
border: 1px solid var(--wk-gris-claro);
|
|
border-radius: 8px;
|
|
font-size: 1rem;
|
|
font-family: inherit;
|
|
background: #fff;
|
|
color: var(--wk-negro);
|
|
width: 100%;
|
|
}
|
|
.field input:focus, .field select:focus, .field textarea:focus {
|
|
outline: 2px solid var(--wk-azul);
|
|
outline-offset: -1px;
|
|
border-color: var(--wk-azul);
|
|
}
|
|
.field input:disabled, .field textarea:disabled, .field select:disabled {
|
|
background: var(--wk-gris-bg);
|
|
color: var(--wk-gris);
|
|
cursor: not-allowed;
|
|
}
|
|
.field .err {
|
|
color: var(--wk-rojo);
|
|
font-size: 0.8rem;
|
|
margin-top: 4px;
|
|
min-height: 0;
|
|
}
|
|
.field.has-error input,
|
|
.field.has-error select,
|
|
.field.has-error textarea {
|
|
border-color: var(--wk-rojo);
|
|
outline-color: var(--wk-rojo);
|
|
}
|
|
|
|
.help {
|
|
font-size: 0.8rem;
|
|
color: var(--wk-gris);
|
|
margin-top: -4px;
|
|
margin-bottom: 10px;
|
|
}
|
|
|
|
.chk {
|
|
display: flex;
|
|
align-items: flex-start;
|
|
gap: 8px;
|
|
padding: 10px 12px;
|
|
border: 1px dashed var(--wk-gris-claro);
|
|
border-radius: 8px;
|
|
background: var(--wk-gris-bg);
|
|
margin-bottom: 12px;
|
|
font-size: 0.95rem;
|
|
}
|
|
.chk input { margin-top: 3px; }
|
|
|
|
.btn {
|
|
display: inline-flex;
|
|
align-items: center;
|
|
justify-content: center;
|
|
gap: 6px;
|
|
padding: 10px 14px;
|
|
border: none;
|
|
border-radius: 8px;
|
|
background: var(--wk-azul);
|
|
color: #fff;
|
|
font-size: 0.95rem;
|
|
font-weight: 600;
|
|
cursor: pointer;
|
|
font-family: inherit;
|
|
}
|
|
.btn:hover { background: var(--wk-azul-oscuro); }
|
|
.btn:disabled { opacity: 0.55; cursor: not-allowed; }
|
|
.btn.ghost {
|
|
background: transparent;
|
|
color: var(--wk-azul);
|
|
border: 1px solid var(--wk-azul);
|
|
}
|
|
.btn.ghost:hover { background: var(--wk-azul); color: #fff; }
|
|
.btn.danger {
|
|
background: transparent;
|
|
color: var(--wk-rojo);
|
|
border: 1px solid var(--wk-gris-claro);
|
|
font-size: 0.85rem;
|
|
padding: 6px 10px;
|
|
}
|
|
.btn.danger:hover { background: #fee2e2; border-color: var(--wk-rojo); }
|
|
|
|
/* --- Tabla del anexo --- */
|
|
.tabla-anexo {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
margin-bottom: 12px;
|
|
}
|
|
.tabla-anexo th {
|
|
text-align: left;
|
|
font-size: 0.8rem;
|
|
font-weight: 600;
|
|
color: var(--wk-gris);
|
|
padding: 0 8px 6px 0;
|
|
text-transform: uppercase;
|
|
letter-spacing: 0.3px;
|
|
}
|
|
.tabla-anexo td {
|
|
padding: 0 8px 8px 0;
|
|
vertical-align: top;
|
|
}
|
|
.tabla-anexo td:last-child, .tabla-anexo th:last-child {
|
|
padding-right: 0;
|
|
width: 44px;
|
|
}
|
|
.tabla-anexo input {
|
|
padding: 10px 12px;
|
|
border: 1px solid var(--wk-gris-claro);
|
|
border-radius: 8px;
|
|
font-size: 1rem;
|
|
font-family: inherit;
|
|
width: 100%;
|
|
}
|
|
.tabla-anexo input:focus {
|
|
outline: 2px solid var(--wk-azul);
|
|
outline-offset: -1px;
|
|
border-color: var(--wk-azul);
|
|
}
|
|
|
|
.counter {
|
|
display: inline-block;
|
|
background: var(--wk-gris-claro);
|
|
color: var(--wk-negro);
|
|
padding: 2px 10px;
|
|
border-radius: 999px;
|
|
font-size: 0.8rem;
|
|
margin-left: 6px;
|
|
}
|
|
|
|
.aviso {
|
|
background: #eff6ff;
|
|
border-left: 3px solid var(--wk-azul);
|
|
padding: 10px 12px;
|
|
font-size: 0.88rem;
|
|
color: var(--wk-azul-oscuro);
|
|
border-radius: 4px;
|
|
margin: 10px 0;
|
|
}
|
|
|
|
.submit-bar {
|
|
position: sticky;
|
|
bottom: 0;
|
|
padding: 14px 0;
|
|
background: linear-gradient(transparent, #fff 40%);
|
|
display: flex;
|
|
justify-content: center;
|
|
}
|
|
.submit-bar .btn { min-width: 220px; font-size: 1rem; padding: 14px 18px; }
|
|
|
|
/* Spinner del botón mientras el POST está en vuelo. */
|
|
.spinner {
|
|
width: 15px;
|
|
height: 15px;
|
|
border: 2px solid rgba(255, 255, 255, 0.4);
|
|
border-top-color: #fff;
|
|
border-radius: 50%;
|
|
animation: girar 0.7s linear infinite;
|
|
}
|
|
@keyframes girar { to { transform: rotate(360deg); } }
|
|
@media (prefers-reduced-motion: reduce) {
|
|
.spinner { animation-duration: 2.5s; }
|
|
}
|
|
|
|
#form-message {
|
|
padding: 12px 14px;
|
|
border-radius: 8px;
|
|
margin: 10px 0;
|
|
font-size: 0.95rem;
|
|
display: none;
|
|
}
|
|
#form-message.ok {
|
|
background: #ecfdf5;
|
|
color: #065f46;
|
|
border: 1px solid #a7f3d0;
|
|
display: block;
|
|
}
|
|
#form-message.err {
|
|
background: #fef2f2;
|
|
color: var(--wk-rojo);
|
|
border: 1px solid #fecaca;
|
|
display: block;
|
|
}
|
|
#form-message ul { margin: 6px 0 0; padding-left: 20px; }
|
|
#form-message .folio {
|
|
display: inline-block;
|
|
font-weight: 700;
|
|
letter-spacing: 0.4px;
|
|
margin-top: 6px;
|
|
}
|
|
|
|
@media (max-width: 480px) {
|
|
.row.inline > .field { flex: 1 1 100%; }
|
|
}
|
|
</style>
|
|
</head>
|
|
<body>
|
|
<div class="wrapper">
|
|
<header class="top">
|
|
<h1>Collina</h1>
|
|
<p>Nuevo acuerdo de confidencialidad</p>
|
|
</header>
|
|
|
|
<form id="nda-form" novalidate>
|
|
|
|
<!-- ---------------- Datos del acuerdo ---------------- -->
|
|
<section class="bloque">
|
|
<h2><span class="tag">A</span> Datos del acuerdo</h2>
|
|
|
|
<div class="field">
|
|
<label for="receptor_nombre">Nombre de El Receptor<span class="req">*</span></label>
|
|
<input type="text" id="receptor_nombre" autocomplete="off"
|
|
placeholder="Nombre completo de la contraparte" />
|
|
<div class="err" data-err-for="receptor_nombre"></div>
|
|
</div>
|
|
|
|
<div class="row inline">
|
|
<div class="field">
|
|
<label for="receptor_tratamiento">Tratamiento</label>
|
|
<select id="receptor_tratamiento">
|
|
<option value="el Sr." selected>el Sr.</option>
|
|
<option value="la Sra.">la Sra.</option>
|
|
<option value="la empresa">la empresa</option>
|
|
</select>
|
|
<div class="err" data-err-for="receptor_tratamiento"></div>
|
|
</div>
|
|
<div class="field">
|
|
<label for="ciudad_firma">Ciudad de firma</label>
|
|
<input type="text" id="ciudad_firma" value="Puebla, Pue." autocomplete="off" />
|
|
<div class="err" data-err-for="ciudad_firma"></div>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="field">
|
|
<label for="fecha_firma">Fecha de firma</label>
|
|
<input type="date" id="fecha_firma" />
|
|
<div class="help">Se escribe en el documento como «A 27 DE marzo DE 2026».</div>
|
|
<div class="err" data-err-for="fecha_firma"></div>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- ---------------- Condiciones ---------------- -->
|
|
<section class="bloque">
|
|
<h2><span class="tag">B</span> Condiciones</h2>
|
|
<div class="help">Déjalos vacíos para usar los valores por defecto del sistema.</div>
|
|
|
|
<div class="field">
|
|
<label for="vigencia_anos_texto">Vigencia</label>
|
|
<input type="text" id="vigencia_anos_texto" placeholder="cinco (5)" autocomplete="off" />
|
|
<div class="err" data-err-for="vigencia_anos_texto"></div>
|
|
</div>
|
|
|
|
<div class="row inline">
|
|
<div class="field">
|
|
<label for="fuero_ciudad">Fuero — ciudad</label>
|
|
<input type="text" id="fuero_ciudad" placeholder="Puebla de Zaragoza" autocomplete="off" />
|
|
<div class="err" data-err-for="fuero_ciudad"></div>
|
|
</div>
|
|
<div class="field">
|
|
<label for="fuero_estado">Fuero — estado</label>
|
|
<input type="text" id="fuero_estado" placeholder="Puebla" autocomplete="off" />
|
|
<div class="err" data-err-for="fuero_estado"></div>
|
|
</div>
|
|
</div>
|
|
</section>
|
|
|
|
<!-- ---------------- Anexo 1 ---------------- -->
|
|
<section class="bloque">
|
|
<h2>
|
|
<span class="tag">C</span> Anexo 1
|
|
<span class="counter" id="anexo_counter" hidden>0 filas</span>
|
|
</h2>
|
|
|
|
<label class="chk">
|
|
<input type="checkbox" id="incluir_anexo" />
|
|
<span>Incluir Anexo 1 con identificaciones</span>
|
|
</label>
|
|
|
|
<div id="anexo_container" hidden>
|
|
<table class="tabla-anexo">
|
|
<thead>
|
|
<tr>
|
|
<th>Parte</th>
|
|
<th>Documento</th>
|
|
<th><span class="sr-only"></span></th>
|
|
</tr>
|
|
</thead>
|
|
<tbody id="anexo_filas"></tbody>
|
|
</table>
|
|
<button type="button" class="btn ghost" id="btn_add_fila">+ Agregar fila</button>
|
|
<div class="err" data-err-for="anexo_partes"></div>
|
|
</div>
|
|
</section>
|
|
|
|
<div id="form-message" role="status" aria-live="polite"></div>
|
|
|
|
<div class="submit-bar">
|
|
<button type="submit" class="btn" id="submit_btn">Generar acuerdo</button>
|
|
</div>
|
|
</form>
|
|
</div>
|
|
|
|
<template id="tpl_fila_anexo">
|
|
<tr>
|
|
<td><input type="text" data-field="parte" placeholder="La Parte Divulgante" /></td>
|
|
<td><input type="text" data-field="documento" placeholder="INE — terminación 1535" /></td>
|
|
<td><button type="button" class="btn danger" data-remove title="Quitar fila">✕</button></td>
|
|
</tr>
|
|
</template>
|
|
|
|
<script>
|
|
(() => {
|
|
'use strict';
|
|
|
|
// -------------------- Session ID desde la URL --------------------
|
|
// El bot manda /form/{session_id} y el backend redirige agregando ?sid=,
|
|
// así que el id viaja en el query string. Ahora va en la URL del POST,
|
|
// no en el body: NDAData es exactamente lo que la plantilla necesita.
|
|
const params = new URLSearchParams(window.location.search);
|
|
const SESSION_ID = params.get('sid') ?? '';
|
|
const ENDPOINT = `/webhook/form/${encodeURIComponent(SESSION_ID)}`;
|
|
|
|
// -------------------- Helpers --------------------
|
|
const $ = (id) => document.getElementById(id);
|
|
const val = (id) => ($(id)?.value ?? '').trim();
|
|
// Los tres campos opcionales viajan como null explícito cuando están
|
|
// vacíos. El backend también acepta "", pero null dice lo que queremos.
|
|
const opcional = (id) => val(id) || null;
|
|
|
|
function setError(campo, mensaje) {
|
|
const caja = document.querySelector(`[data-err-for="${campo}"]`);
|
|
if (!caja) return false;
|
|
caja.textContent = mensaje;
|
|
caja.closest('.field')?.classList.add('has-error');
|
|
return true;
|
|
}
|
|
function clearErrors() {
|
|
document.querySelectorAll('.err').forEach(e => { e.textContent = ''; });
|
|
document.querySelectorAll('.has-error').forEach(e => e.classList.remove('has-error'));
|
|
}
|
|
|
|
// -------------------- Fecha de firma: default hoy --------------------
|
|
(() => {
|
|
const hoy = new Date();
|
|
const iso = [
|
|
hoy.getFullYear(),
|
|
String(hoy.getMonth() + 1).padStart(2, '0'),
|
|
String(hoy.getDate()).padStart(2, '0')
|
|
].join('-');
|
|
$('fecha_firma').value = iso;
|
|
})();
|
|
|
|
// -------------------- Anexo 1 --------------------
|
|
const chkAnexo = $('incluir_anexo');
|
|
const contAnexo = $('anexo_container');
|
|
const filas = $('anexo_filas');
|
|
const contador = $('anexo_counter');
|
|
const tpl = $('tpl_fila_anexo');
|
|
|
|
function actualizarContador() {
|
|
const n = filas.children.length;
|
|
contador.textContent = n === 1 ? '1 fila' : `${n} filas`;
|
|
contador.hidden = !chkAnexo.checked;
|
|
}
|
|
|
|
function agregarFila(parte = '', documento = '') {
|
|
const nodo = tpl.content.cloneNode(true);
|
|
nodo.querySelector('[data-field="parte"]').value = parte;
|
|
nodo.querySelector('[data-field="documento"]').value = documento;
|
|
nodo.querySelector('[data-remove]').addEventListener('click', (e) => {
|
|
e.target.closest('tr').remove();
|
|
actualizarContador();
|
|
});
|
|
filas.appendChild(nodo);
|
|
actualizarContador();
|
|
}
|
|
|
|
$('btn_add_fila').addEventListener('click', () => agregarFila());
|
|
|
|
chkAnexo.addEventListener('change', () => {
|
|
contAnexo.hidden = !chkAnexo.checked;
|
|
// Precarga las dos partes del acuerdo la primera vez que se activa.
|
|
if (chkAnexo.checked && filas.children.length === 0) {
|
|
agregarFila('La Parte Divulgante', '');
|
|
agregarFila('El Receptor', '');
|
|
}
|
|
actualizarContador();
|
|
});
|
|
|
|
function leerAnexo() {
|
|
return Array.from(filas.children).map(tr => ({
|
|
parte: tr.querySelector('[data-field="parte"]').value.trim(),
|
|
documento: tr.querySelector('[data-field="documento"]').value.trim()
|
|
})).filter(f => f.parte || f.documento);
|
|
}
|
|
|
|
// -------------------- Payload --------------------
|
|
function buildPayload() {
|
|
const incluir = chkAnexo.checked;
|
|
return {
|
|
receptor_nombre: val('receptor_nombre'),
|
|
receptor_tratamiento: val('receptor_tratamiento') || 'el Sr.',
|
|
ciudad_firma: val('ciudad_firma') || 'Puebla, Pue.',
|
|
fecha_firma: val('fecha_firma'),
|
|
vigencia_anos_texto: opcional('vigencia_anos_texto'),
|
|
fuero_ciudad: opcional('fuero_ciudad'),
|
|
fuero_estado: opcional('fuero_estado'),
|
|
incluir_anexo: incluir,
|
|
anexo_partes: incluir ? leerAnexo() : []
|
|
};
|
|
}
|
|
|
|
// -------------------- Validación local --------------------
|
|
// Mínima a propósito: la fuente de verdad es Pydantic. Solo adelantamos
|
|
// lo que evita un viaje al servidor.
|
|
function validar() {
|
|
clearErrors();
|
|
let ok = true;
|
|
if (!val('receptor_nombre')) {
|
|
setError('receptor_nombre', 'Escribe el nombre de El Receptor.');
|
|
ok = false;
|
|
}
|
|
if (chkAnexo.checked && leerAnexo().length === 0) {
|
|
setError('anexo_partes', 'Agrega al menos una fila o desactiva el anexo.');
|
|
ok = false;
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
// -------------------- Mensajes --------------------
|
|
const msgBox = $('form-message');
|
|
|
|
function mostrarMensaje(tipo, html) {
|
|
msgBox.className = tipo;
|
|
msgBox.innerHTML = html;
|
|
msgBox.scrollIntoView({ behavior: 'smooth', block: 'center' });
|
|
}
|
|
function ocultarMensaje() {
|
|
msgBox.className = '';
|
|
msgBox.textContent = '';
|
|
msgBox.style.display = 'none';
|
|
}
|
|
const escapar = (s) => String(s).replace(/[&<>"']/g, c => (
|
|
{ '&': '&', '<': '<', '>': '>', '"': '"', "'": ''' }[c]
|
|
));
|
|
|
|
// Etiquetas legibles para los errores 422 de Pydantic.
|
|
const ETIQUETAS = {
|
|
receptor_nombre: 'Nombre de El Receptor',
|
|
receptor_tratamiento: 'Tratamiento',
|
|
ciudad_firma: 'Ciudad de firma',
|
|
fecha_firma: 'Fecha de firma',
|
|
vigencia_anos_texto: 'Vigencia',
|
|
fuero_ciudad: 'Fuero — ciudad',
|
|
fuero_estado: 'Fuero — estado',
|
|
incluir_anexo: 'Anexo 1',
|
|
anexo_partes: 'Filas del anexo'
|
|
};
|
|
|
|
/**
|
|
* Convierte el `detail` de un 422 de FastAPI en mensajes por campo.
|
|
* Cada entrada trae `loc` (p.ej. ["body","receptor_nombre"]) y `msg`.
|
|
* Los pinta junto al campo cuando existe la caja; devuelve la lista de
|
|
* los que no pudo colocar para mostrarlos arriba.
|
|
*/
|
|
function pintarErrores422(detail) {
|
|
const sueltos = [];
|
|
if (!Array.isArray(detail)) {
|
|
sueltos.push(typeof detail === 'string' ? detail : 'Datos inválidos.');
|
|
return sueltos;
|
|
}
|
|
for (const e of detail) {
|
|
const loc = Array.isArray(e.loc) ? e.loc.filter(x => x !== 'body') : [];
|
|
const campo = loc[0];
|
|
// Pydantic antepone "Value error, " a los mensajes de los validadores.
|
|
const mensaje = (e.msg || 'Valor inválido').replace(/^Value error,\s*/, '');
|
|
const etiqueta = ETIQUETAS[campo] || campo || 'Formulario';
|
|
if (!campo || !setError(campo, mensaje)) {
|
|
sueltos.push(`${etiqueta}: ${mensaje}`);
|
|
}
|
|
}
|
|
return sueltos;
|
|
}
|
|
|
|
const MSG_SESION = 'Este link ya no es válido. Escribe <em>nuevo acuerdo</em> ' +
|
|
'por WhatsApp para recibir uno nuevo.';
|
|
|
|
// -------------------- Submit --------------------
|
|
const form = $('nda-form');
|
|
const submitBtn = $('submit_btn');
|
|
|
|
form.addEventListener('submit', async (e) => {
|
|
e.preventDefault();
|
|
ocultarMensaje();
|
|
|
|
if (!SESSION_ID) {
|
|
mostrarMensaje('err', MSG_SESION);
|
|
return;
|
|
}
|
|
if (!validar()) {
|
|
mostrarMensaje('err', 'Revisa los campos marcados en rojo antes de continuar.');
|
|
return;
|
|
}
|
|
|
|
const textoOriginal = submitBtn.textContent;
|
|
submitBtn.disabled = true;
|
|
submitBtn.innerHTML = '<span class="spinner"></span> Generando...';
|
|
|
|
try {
|
|
const res = await fetch(ENDPOINT, {
|
|
method: 'POST',
|
|
headers: { 'Content-Type': 'application/json' },
|
|
body: JSON.stringify(buildPayload())
|
|
});
|
|
|
|
if (res.status === 422) {
|
|
let detail = null;
|
|
try { detail = (await res.json()).detail; } catch {}
|
|
const sueltos = pintarErrores422(detail);
|
|
const lista = sueltos.length
|
|
? `<ul>${sueltos.map(s => `<li>${escapar(s)}</li>`).join('')}</ul>`
|
|
: '';
|
|
mostrarMensaje('err', `Revisa los datos del formulario.${lista}`);
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = textoOriginal;
|
|
return;
|
|
}
|
|
|
|
if (res.status === 404 || res.status === 410) {
|
|
mostrarMensaje('err', MSG_SESION);
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = textoOriginal;
|
|
return;
|
|
}
|
|
|
|
if (!res.ok) {
|
|
let detalle = '';
|
|
try {
|
|
const data = await res.json();
|
|
if (typeof data.detail === 'string') detalle = ` ${data.detail}`;
|
|
} catch {}
|
|
throw new Error(`No se pudo generar el acuerdo (error ${res.status}).${detalle}`);
|
|
}
|
|
|
|
const data = await res.json().catch(() => ({}));
|
|
const folio = data.numero_contrato
|
|
? `<span class="folio">Folio ${escapar(data.numero_contrato)}</span>`
|
|
: '';
|
|
mostrarMensaje('ok',
|
|
'✓ Acuerdo de confidencialidad generado. Te llega por WhatsApp en unos segundos.<br>' + folio);
|
|
submitBtn.textContent = 'Enviado';
|
|
} catch (err) {
|
|
mostrarMensaje('err', escapar(err.message || 'No se pudo generar el acuerdo.'));
|
|
submitBtn.disabled = false;
|
|
submitBtn.textContent = textoOriginal;
|
|
}
|
|
});
|
|
})();
|
|
</script>
|
|
</body>
|
|
</html>
|