196 lines
11 KiB
HTML
196 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="es">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>Configuración - IntegraRepara</title>
|
|
<script src="https://cdn.tailwindcss.com"></script>
|
|
<script src="https://unpkg.com/lucide@latest"></script>
|
|
<style>
|
|
.fade-in { animation: fadeIn 0.3s ease-in-out; }
|
|
.scroller::-webkit-scrollbar { width: 6px; }
|
|
.scroller::-webkit-scrollbar-thumb { background-color: #cbd5e1; border-radius: 4px; }
|
|
</style>
|
|
</head>
|
|
<body class="bg-gray-50 text-gray-800 font-sans h-screen overflow-hidden flex">
|
|
|
|
<div id="sidebar-container" class="h-full shrink-0"></div>
|
|
|
|
<div class="flex-1 flex flex-col h-full relative min-w-0">
|
|
<div id="header-container"></div>
|
|
|
|
<main class="flex-1 flex flex-col overflow-hidden relative">
|
|
|
|
<div class="bg-gray-50 p-6 pb-0 z-20 shrink-0">
|
|
<h2 class="text-2xl font-bold text-gray-800 mb-6 flex items-center gap-2">
|
|
<i data-lucide="settings" class="text-blue-600"></i> Configuración Avanzada
|
|
</h2>
|
|
|
|
<div class="flex border-b border-gray-200 overflow-x-auto no-scrollbar">
|
|
<button onclick="showTab('templates')" id="tab-templates" class="tab-btn px-6 py-3 text-sm font-bold text-blue-600 border-b-2 border-blue-600 hover:bg-gray-100 transition whitespace-nowrap">
|
|
<i data-lucide="file-text" class="inline w-4 h-4 mr-1"></i> Plantillas
|
|
</button>
|
|
<button onclick="showTab('whatsapp')" id="tab-whatsapp" class="tab-btn px-6 py-3 text-sm font-medium text-gray-500 hover:text-blue-600 hover:bg-gray-100 transition whitespace-nowrap">
|
|
<i data-lucide="message-circle" class="inline w-4 h-4 mr-1"></i> WhatsApp
|
|
</button>
|
|
<button onclick="showTab('providers')" id="tab-providers" class="tab-btn px-6 py-3 text-sm font-medium text-gray-500 hover:text-blue-600 hover:bg-gray-100 transition whitespace-nowrap">
|
|
<i data-lucide="truck" class="inline w-4 h-4 mr-1"></i> Proveedores
|
|
</button>
|
|
<button onclick="showTab('portal')" id="tab-portal" class="tab-btn px-6 py-3 text-sm font-medium text-gray-500 hover:text-blue-600 hover:bg-gray-100 transition whitespace-nowrap">
|
|
<i data-lucide="globe" class="inline w-4 h-4 mr-1"></i> Portal Cliente
|
|
</button>
|
|
<button onclick="showTab('others')" id="tab-others" class="tab-btn px-6 py-3 text-sm font-medium text-gray-500 hover:text-blue-600 hover:bg-gray-100 transition whitespace-nowrap">
|
|
<i data-lucide="sliders" class="inline w-4 h-4 mr-1"></i> Otras Configuraciones
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="flex-1 overflow-hidden p-6 bg-gray-50">
|
|
|
|
<div id="view-templates" class="tab-content h-full fade-in">
|
|
<div class="bg-white rounded-xl shadow p-10 text-center border border-gray-100">
|
|
<i data-lucide="file-text" class="w-16 h-16 text-gray-200 mx-auto mb-4"></i>
|
|
<h3 class="text-xl font-bold text-gray-700">Gestor de Plantillas</h3>
|
|
<p class="text-gray-500 mt-2">Próximamente podrás editar tus textos aquí.</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="view-whatsapp" class="tab-content hidden h-full fade-in">
|
|
<div class="bg-white rounded-xl shadow p-10 text-center border border-gray-100">
|
|
<i data-lucide="message-circle" class="w-16 h-16 text-green-100 mx-auto mb-4 text-green-500"></i>
|
|
<h3 class="text-xl font-bold text-gray-700">Conexión WhatsApp</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="view-providers" class="tab-content hidden h-full fade-in">
|
|
<div class="bg-white rounded-xl shadow p-10 text-center border border-gray-100">
|
|
<i data-lucide="truck" class="w-16 h-16 text-gray-200 mx-auto mb-4"></i>
|
|
<h3 class="text-xl font-bold text-gray-700">Proveedores</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="view-portal" class="tab-content hidden h-full fade-in">
|
|
<div class="bg-white rounded-xl shadow p-10 text-center border border-gray-100">
|
|
<i data-lucide="globe" class="w-16 h-16 text-blue-200 mx-auto mb-4"></i>
|
|
<h3 class="text-xl font-bold text-gray-700">Portal del Cliente</h3>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="view-others" class="tab-content hidden h-full fade-in flex flex-col">
|
|
|
|
<div class="grid grid-cols-1 md:grid-cols-2 gap-6">
|
|
<div class="bg-white rounded-xl shadow border border-gray-100 flex flex-col h-[500px]">
|
|
<div class="p-4 bg-gray-50 border-b border-gray-200 shrink-0">
|
|
<h3 class="font-bold text-gray-700 flex items-center gap-2">
|
|
<i data-lucide="shield" class="w-4 h-4 text-blue-600"></i> Compañías de Seguros
|
|
</h3>
|
|
</div>
|
|
|
|
<div class="p-4 border-b border-gray-100 bg-white">
|
|
<div class="flex gap-2">
|
|
<input type="text" id="newCompanyInput" placeholder="Nombre de la compañía..." class="flex-1 border rounded-lg px-3 py-2 text-sm outline-none focus:border-blue-500">
|
|
<button onclick="addCompany()" class="bg-blue-600 hover:bg-blue-700 text-white px-4 py-2 rounded-lg text-xs font-bold transition-colors">
|
|
Añadir
|
|
</button>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="listCompanies" class="flex-1 overflow-y-auto scroller p-2 space-y-1">
|
|
<p class="text-center text-xs text-gray-400 mt-10">Cargando...</p>
|
|
</div>
|
|
</div>
|
|
|
|
<div class="bg-white rounded-xl shadow border border-gray-100 p-6 flex items-center justify-center text-gray-400 text-sm">
|
|
<p>Más configuraciones próximamente...</p>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
</main>
|
|
</div>
|
|
|
|
<div id="toast" class="fixed bottom-5 right-5 bg-slate-800 text-white px-6 py-3 rounded-lg shadow-2xl transform translate-y-20 opacity-0 transition-all duration-300 z-50 flex items-center gap-3"><span id="toastMsg">Msg</span></div>
|
|
|
|
<script src="js/layout.js"></script>
|
|
<script>
|
|
document.addEventListener("DOMContentLoaded", () => {
|
|
if (!localStorage.getItem("token")) window.location.href = "index.html";
|
|
showTab('templates'); // Pestaña por defecto
|
|
});
|
|
|
|
function showTab(tabId) {
|
|
document.querySelectorAll('.tab-content').forEach(el => el.classList.add('hidden'));
|
|
document.getElementById(`view-${tabId}`).classList.remove('hidden');
|
|
|
|
document.querySelectorAll('.tab-btn').forEach(el => {
|
|
el.classList.remove('text-blue-600', 'border-b-2', 'border-blue-600', 'font-bold');
|
|
el.classList.add('text-gray-500', 'font-medium');
|
|
});
|
|
const btn = document.getElementById(`tab-${tabId}`);
|
|
btn.classList.add('text-blue-600', 'border-b-2', 'border-blue-600', 'font-bold');
|
|
btn.classList.remove('text-gray-500', 'font-medium');
|
|
|
|
// Cargar datos si entramos en "Otras Configuraciones"
|
|
if(tabId === 'others') {
|
|
loadCompanies();
|
|
}
|
|
}
|
|
|
|
// --- GESTIÓN DE COMPAÑÍAS ---
|
|
async function loadCompanies() {
|
|
const list = document.getElementById('listCompanies');
|
|
list.innerHTML = '<p class="text-center text-xs text-gray-400 mt-10">Cargando...</p>';
|
|
|
|
try {
|
|
const res = await fetch(`${API_URL}/companies`, { headers: { "Authorization": `Bearer ${localStorage.getItem("token")}` } });
|
|
const data = await res.json();
|
|
|
|
list.innerHTML = "";
|
|
if(data.companies.length === 0) {
|
|
list.innerHTML = '<p class="text-center text-xs text-gray-400 mt-4">No hay compañías registradas.</p>';
|
|
return;
|
|
}
|
|
|
|
data.companies.forEach(c => {
|
|
const div = document.createElement('div');
|
|
div.className = "p-3 border border-gray-100 rounded-lg bg-gray-50 flex justify-between items-center group hover:border-blue-200 transition-colors";
|
|
div.innerHTML = `
|
|
<span class="font-bold text-gray-700 text-sm">${c.name}</span>
|
|
<i data-lucide="building-2" class="w-4 h-4 text-gray-300"></i>
|
|
`;
|
|
list.appendChild(div);
|
|
});
|
|
lucide.createIcons();
|
|
} catch(e) { list.innerHTML = '<p class="text-red-500 text-xs text-center">Error al cargar</p>'; }
|
|
}
|
|
|
|
async function addCompany() {
|
|
const input = document.getElementById('newCompanyInput');
|
|
const name = input.value.trim();
|
|
if(!name) return;
|
|
|
|
try {
|
|
const res = await fetch(`${API_URL}/companies`, {
|
|
method: 'POST',
|
|
headers: { "Content-Type": "application/json", "Authorization": `Bearer ${localStorage.getItem("token")}` },
|
|
body: JSON.stringify({ name: name })
|
|
});
|
|
if(res.ok) {
|
|
showToast("Compañía añadida");
|
|
input.value = "";
|
|
loadCompanies();
|
|
} else { showToast("Error al añadir", true); }
|
|
} catch(e) { showToast("Error de conexión", true); }
|
|
}
|
|
|
|
function showToast(msg, isError = false) {
|
|
const t = document.getElementById('toast'), m = document.getElementById('toastMsg');
|
|
t.className = `fixed bottom-5 right-5 px-6 py-3 rounded-lg shadow-xl transition-all duration-300 z-50 flex items-center gap-3 ${isError ? 'bg-red-600' : 'bg-slate-800'} text-white font-medium`;
|
|
m.innerText = msg; t.classList.remove('translate-y-20', 'opacity-0');
|
|
setTimeout(() => t.classList.add('translate-y-20', 'opacity-0'), 3000);
|
|
}
|
|
</script>
|
|
</body>
|
|
</html> |