Actualizar configuracion.html
This commit is contained in:
@@ -60,6 +60,19 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bg-white rounded-[2.5rem] p-6 shadow-sm border border-slate-100">
|
||||
<div class="flex items-center gap-3 mb-4">
|
||||
<div class="bg-pink-100 p-2 rounded-xl text-pink-600"><i data-lucide="instagram" class="w-5 h-5"></i></div>
|
||||
<h3 class="font-black text-slate-800 uppercase text-xs tracking-widest">Mensaje de Instagram</h3>
|
||||
</div>
|
||||
<p class="text-[10px] font-medium text-slate-400 uppercase mb-3">Se envía por WhatsApp al pulsar "Enviar Instagram" en un servicio</p>
|
||||
<textarea id="instaMsg" rows="5" class="w-full bg-slate-50 border border-slate-200 p-4 rounded-xl text-sm font-medium text-slate-700 shadow-inner outline-none focus:ring-2 focus:ring-pink-500 transition-all"></textarea>
|
||||
<div class="flex items-center gap-2 mt-3">
|
||||
<button onclick="saveInstagramMessage()" class="flex-1 bg-pink-500 text-white font-black py-3 rounded-xl uppercase text-[10px] tracking-widest active:scale-95 transition-transform">Guardar</button>
|
||||
<button onclick="restoreDefaultInstagramMessage()" class="bg-slate-100 text-slate-500 font-black py-3 px-4 rounded-xl uppercase text-[10px] tracking-widest active:scale-95 transition-transform">Restaurar</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a href="comparador-luz.html" class="block bg-white rounded-[2.5rem] p-6 shadow-sm border border-slate-100 active:scale-[0.98] transition-transform">
|
||||
<div class="flex items-center justify-between">
|
||||
<div class="flex items-center gap-3">
|
||||
@@ -76,16 +89,56 @@
|
||||
</main>
|
||||
|
||||
<script>
|
||||
const API_URL = window.location.hostname === 'localhost' || window.location.hostname === '127.0.0.1'
|
||||
? 'http://localhost:3000'
|
||||
: 'https://integrarepara-api.integrarepara.es';
|
||||
|
||||
document.addEventListener("DOMContentLoaded", () => {
|
||||
lucide.createIcons();
|
||||
const isAuto = localStorage.getItem("auto_homeserve") === "true";
|
||||
document.getElementById('toggleHS').checked = isAuto;
|
||||
loadInstagramMessage();
|
||||
});
|
||||
|
||||
function saveConfig() {
|
||||
const isChecked = document.getElementById('toggleHS').checked;
|
||||
localStorage.setItem("auto_homeserve", isChecked);
|
||||
}
|
||||
|
||||
async function loadInstagramMessage() {
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/whatsapp/settings`, {
|
||||
headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok) {
|
||||
document.getElementById('instaMsg').value = data.instagram_promo_message || data.default_instagram_promo_message || '';
|
||||
}
|
||||
} catch (e) { /* si falla, se deja vacío y el usuario puede escribir el suyo */ }
|
||||
}
|
||||
|
||||
async function saveInstagramMessage() {
|
||||
const mensaje = document.getElementById('instaMsg').value;
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/whatsapp/settings`, {
|
||||
method: 'POST',
|
||||
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
||||
body: JSON.stringify({ instagram_promo_message: mensaje })
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok) alert("¡Mensaje guardado!"); else alert("No se pudo guardar.");
|
||||
} catch (e) { alert("Error de conexión al guardar."); }
|
||||
}
|
||||
|
||||
async function restoreDefaultInstagramMessage() {
|
||||
try {
|
||||
const res = await fetch(`${API_URL}/whatsapp/settings`, {
|
||||
headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` }
|
||||
});
|
||||
const data = await res.json();
|
||||
if (data.ok) document.getElementById('instaMsg').value = data.default_instagram_promo_message || '';
|
||||
} catch (e) { alert("Error de conexión."); }
|
||||
}
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user