Actualizar index.html
This commit is contained in:
507
index.html
507
index.html
@@ -3,262 +3,289 @@
|
|||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>Portal del Cliente | IntegraRepara</title>
|
<title>Mi Área de Cliente | IntegraRepara</title>
|
||||||
<link href="https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap" rel="stylesheet">
|
<script src="https://cdn.tailwindcss.com"></script>
|
||||||
|
<script src="https://unpkg.com/lucide@latest"></script>
|
||||||
<style>
|
<style>
|
||||||
/* Estilos generales (Reset básico) */
|
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;700;900&display=swap');
|
||||||
* {
|
body { font-family: 'Inter', sans-serif; background-color: #f8fafc; }
|
||||||
margin: 0;
|
.fade-in { animation: fadeIn 0.4s ease-out forwards; }
|
||||||
padding: 0;
|
@keyframes fadeIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
|
||||||
box-sizing: border-box;
|
.pulse-soft { animation: pulseSoft 2s infinite; }
|
||||||
font-family: 'Inter', sans-serif;
|
@keyframes pulseSoft { 0%, 100% { opacity: 1; } 50% { opacity: 0.7; } }
|
||||||
}
|
.no-scrollbar::-webkit-scrollbar { display: none; }
|
||||||
|
|
||||||
body {
|
|
||||||
background-color: #f3f4f6; /* Gris muy clarito de fondo */
|
|
||||||
color: #1f2937;
|
|
||||||
display: flex;
|
|
||||||
min-height: 100vh;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- MENÚ LATERAL (Sidebar) --- */
|
|
||||||
.sidebar {
|
|
||||||
width: 260px;
|
|
||||||
background-color: #111827; /* Azul oscuro casi negro */
|
|
||||||
color: white;
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo {
|
|
||||||
font-size: 1.5rem;
|
|
||||||
font-weight: 700;
|
|
||||||
margin-bottom: 40px;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.logo span { color: #3b82f6; } /* Azul para la palabra Repara */
|
|
||||||
|
|
||||||
.nav-menu {
|
|
||||||
list-style: none;
|
|
||||||
flex-grow: 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-item {
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-link {
|
|
||||||
display: block;
|
|
||||||
padding: 12px 15px;
|
|
||||||
color: #9ca3af;
|
|
||||||
text-decoration: none;
|
|
||||||
border-radius: 8px;
|
|
||||||
transition: all 0.3s ease;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.nav-link:hover, .nav-link.active {
|
|
||||||
background-color: #1f2937;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- ÁREA PRINCIPAL --- */
|
|
||||||
.main-content {
|
|
||||||
flex-grow: 1;
|
|
||||||
padding: 30px 40px;
|
|
||||||
overflow-y: auto;
|
|
||||||
}
|
|
||||||
|
|
||||||
header {
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
margin-bottom: 30px;
|
|
||||||
padding-bottom: 20px;
|
|
||||||
border-bottom: 1px solid #e5e7eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
header h1 {
|
|
||||||
font-size: 1.8rem;
|
|
||||||
color: #111827;
|
|
||||||
}
|
|
||||||
|
|
||||||
.user-info {
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
gap: 15px;
|
|
||||||
font-weight: 500;
|
|
||||||
}
|
|
||||||
|
|
||||||
.avatar {
|
|
||||||
width: 40px;
|
|
||||||
height: 40px;
|
|
||||||
background-color: #3b82f6;
|
|
||||||
color: white;
|
|
||||||
border-radius: 50%;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
font-weight: bold;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- TARJETAS DE RESUMEN (KPIs) --- */
|
|
||||||
.stats-grid {
|
|
||||||
display: grid;
|
|
||||||
grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
|
|
||||||
gap: 20px;
|
|
||||||
margin-bottom: 40px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card {
|
|
||||||
background: white;
|
|
||||||
padding: 20px;
|
|
||||||
border-radius: 12px;
|
|
||||||
box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
|
|
||||||
border: 1px solid #e5e7eb;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card h3 {
|
|
||||||
font-size: 0.875rem;
|
|
||||||
color: #6b7280;
|
|
||||||
text-transform: uppercase;
|
|
||||||
letter-spacing: 0.05em;
|
|
||||||
margin-bottom: 10px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.stat-card .value {
|
|
||||||
font-size: 2rem;
|
|
||||||
font-weight: 700;
|
|
||||||
color: #111827;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* --- SECCIÓN DE LA TARJETA DEL PARTE --- */
|
|
||||||
.section-title {
|
|
||||||
font-size: 1.25rem;
|
|
||||||
margin-bottom: 20px;
|
|
||||||
color: #111827;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Reutilizamos los estilos de la tarjeta que hicimos antes */
|
|
||||||
.integra-card {
|
|
||||||
background: #ffffff;
|
|
||||||
border-radius: 12px;
|
|
||||||
box-shadow: 0 10px 25px rgba(0,0,0,0.1);
|
|
||||||
width: 100%;
|
|
||||||
max-width: 600px;
|
|
||||||
overflow: hidden;
|
|
||||||
border: 1px solid #e5e7eb;
|
|
||||||
}
|
|
||||||
.integra-header {
|
|
||||||
background: #1e293b;
|
|
||||||
color: #ffffff;
|
|
||||||
padding: 20px;
|
|
||||||
display: flex;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
|
||||||
}
|
|
||||||
.integra-header h3 { margin: 0; font-size: 1.1rem; }
|
|
||||||
.integra-badge { background: #f59e0b; color: #fff; padding: 4px 10px; border-radius: 20px; font-size: 0.8rem; font-weight: bold; }
|
|
||||||
.integra-body { padding: 20px; }
|
|
||||||
.integra-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; margin-bottom: 20px; font-size: 0.9rem; }
|
|
||||||
.integra-label { font-size: 0.75rem; color: #6b7280; text-transform: uppercase; margin-bottom: 3px; }
|
|
||||||
.integra-value { font-weight: 500; color: #111827; }
|
|
||||||
.integra-description { background: #f3f4f6; padding: 15px; border-radius: 8px; font-size: 0.9rem; margin-bottom: 20px; border-left: 4px solid #3b82f6; }
|
|
||||||
.integra-tracker { padding-left: 20px; margin-top: 20px; }
|
|
||||||
.integra-step { position: relative; padding-bottom: 20px; font-size: 0.9rem; }
|
|
||||||
.integra-step::before { content: ''; position: absolute; left: -20px; top: 4px; width: 12px; height: 12px; border-radius: 50%; background: #d1d5db; }
|
|
||||||
.integra-step:not(:last-child)::after { content: ''; position: absolute; left: -15px; top: 16px; width: 2px; height: 100%; background: #d1d5db; }
|
|
||||||
.integra-step.completed::before, .integra-step.completed::after { background: #10b981; }
|
|
||||||
.integra-step.active::before { background: #3b82f6; box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3); }
|
|
||||||
.integra-step.active { font-weight: bold; color: #111827; }
|
|
||||||
|
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body class="text-slate-800 antialiased min-h-screen flex flex-col relative pb-24">
|
||||||
|
|
||||||
<aside class="sidebar">
|
<div id="loader" class="fixed inset-0 bg-slate-50 z-50 flex flex-col items-center justify-center transition-opacity duration-300">
|
||||||
<div class="logo">
|
<i data-lucide="loader-2" class="w-10 h-10 text-blue-600 animate-spin mb-4"></i>
|
||||||
Integra<span>Repara</span>
|
<p class="text-slate-500 font-bold text-sm tracking-widest uppercase animate-pulse">Cargando tu portal...</p>
|
||||||
</div>
|
</div>
|
||||||
<ul class="nav-menu">
|
|
||||||
<li class="nav-item"><a href="#" class="nav-link active">Panel Principal</a></li>
|
|
||||||
<li class="nav-item"><a href="#" class="nav-link">Mis Avisos (3)</a></li>
|
|
||||||
<li class="nav-item"><a href="#" class="nav-link">Presupuestos</a></li>
|
|
||||||
<li class="nav-item"><a href="#" class="nav-link">Facturas</a></li>
|
|
||||||
<li class="nav-item"><a href="#" class="nav-link">Configuración</a></li>
|
|
||||||
</ul>
|
|
||||||
</aside>
|
|
||||||
|
|
||||||
<main class="main-content">
|
<div id="errorScreen" class="fixed inset-0 bg-slate-50 z-40 hidden flex-col items-center justify-center p-6 text-center">
|
||||||
<header>
|
<div class="bg-red-100 p-4 rounded-full text-red-500 mb-4 shadow-sm">
|
||||||
<h1>Hola, Empresa Demo S.L. 👋</h1>
|
<i data-lucide="shield-alert" class="w-10 h-10"></i>
|
||||||
<div class="user-info">
|
</div>
|
||||||
<span>Administrador</span>
|
<h2 class="text-2xl font-black text-slate-800 mb-2">Enlace no válido</h2>
|
||||||
<div class="avatar">ED</div>
|
<p class="text-slate-500 max-w-sm mb-6">Parece que este enlace ha caducado o no es correcto. Por favor, solicita un nuevo acceso a tu empresa de reparaciones.</p>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<header class="bg-slate-900 text-white pt-10 pb-6 px-6 rounded-b-[2.5rem] shadow-xl relative overflow-hidden shrink-0 z-10">
|
||||||
|
<div class="absolute -top-24 -right-24 w-48 h-48 bg-blue-500 rounded-full mix-blend-multiply filter blur-3xl opacity-20 pulse-soft"></div>
|
||||||
|
<div class="absolute top-10 -left-10 w-32 h-32 bg-purple-500 rounded-full mix-blend-multiply filter blur-3xl opacity-20 pulse-soft" style="animation-delay: 1s;"></div>
|
||||||
|
|
||||||
|
<div class="relative z-10 flex justify-between items-center max-w-3xl mx-auto">
|
||||||
|
<div>
|
||||||
|
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-widest mb-1">Área Privada</p>
|
||||||
|
<h1 id="uiCompanyName" class="text-xl font-black tracking-tight text-white flex items-center gap-2">
|
||||||
|
<div class="w-2 h-2 bg-blue-500 rounded-full"></div> Cargando...
|
||||||
|
</h1>
|
||||||
|
</div>
|
||||||
|
<div class="bg-white/10 p-2.5 rounded-2xl backdrop-blur-md border border-white/10">
|
||||||
|
<i data-lucide="user" class="w-5 h-5 text-blue-300"></i>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
|
||||||
<div class="stats-grid">
|
<main id="mainContent" class="flex-1 px-6 pt-6 max-w-3xl mx-auto w-full hidden flex-col gap-6">
|
||||||
<div class="stat-card">
|
|
||||||
<h3>Avisos en Curso</h3>
|
<div class="fade-in" style="animation-delay: 0.1s;">
|
||||||
<div class="value">12</div>
|
<h2 class="text-3xl font-black text-slate-800 tracking-tight leading-none mb-1">Hola, <span id="uiClientName" class="text-blue-600"></span>👋</h2>
|
||||||
</div>
|
<p class="text-sm text-slate-500 font-medium mb-6">Aquí tienes el estado en tiempo real de tus reparaciones.</p>
|
||||||
<div class="stat-card">
|
|
||||||
<h3>Pendientes de Asignar</h3>
|
<button onclick="openNewRequestModal()" class="w-full bg-blue-600 hover:bg-blue-700 text-white font-black py-4 px-6 rounded-[1.5rem] shadow-[0_8px_20px_-6px_rgba(37,99,235,0.5)] transition-all active:scale-95 flex items-center justify-between group">
|
||||||
<div class="value" style="color: #ef4444;">3</div>
|
<div class="flex items-center gap-3">
|
||||||
</div>
|
<div class="bg-white/20 p-2 rounded-xl group-hover:scale-110 transition-transform"><i data-lucide="wrench" class="w-5 h-5"></i></div>
|
||||||
<div class="stat-card">
|
<span class="uppercase tracking-wide text-sm">Solicitar Reparación</span>
|
||||||
<h3>Avisos Completados (Mes)</h3>
|
|
||||||
<div class="value" style="color: #10b981;">48</div>
|
|
||||||
</div>
|
</div>
|
||||||
|
<i data-lucide="arrow-right" class="w-5 h-5 opacity-70 group-hover:opacity-100 group-hover:translate-x-1 transition-all"></i>
|
||||||
|
</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<h2 class="section-title">Último Parte Actualizado</h2>
|
<div class="fade-in flex flex-col gap-4" style="animation-delay: 0.2s;">
|
||||||
|
<h3 class="font-black text-xs uppercase tracking-widest text-slate-400 ml-2 mt-4 flex items-center gap-2">
|
||||||
|
<i data-lucide="history" class="w-3.5 h-3.5"></i> Tu Historial
|
||||||
|
</h3>
|
||||||
|
|
||||||
<div class="integra-card">
|
<div id="servicesContainer" class="flex flex-col gap-4">
|
||||||
<div class="integra-header">
|
|
||||||
<h3>Parte #IR-26049</h3>
|
|
||||||
<span class="integra-badge">En Curso</span>
|
|
||||||
</div>
|
|
||||||
<div class="integra-body">
|
|
||||||
<div class="integra-grid">
|
|
||||||
<div>
|
|
||||||
<div class="integra-label">Cliente Final</div>
|
|
||||||
<div class="integra-value">Juan Pérez</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="integra-label">Fecha del Aviso</div>
|
|
||||||
<div class="integra-value">18 Feb 2026</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="integra-label">Técnico Asignado</div>
|
|
||||||
<div class="integra-value">Carlos G. (Fontanería)</div>
|
|
||||||
</div>
|
|
||||||
<div>
|
|
||||||
<div class="integra-label">Compañía</div>
|
|
||||||
<div class="integra-value">Seguros Hogar S.A.</div>
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="integra-description">
|
|
||||||
<strong>Avería reportada:</strong> Fuga de agua en la parte inferior de la lavadora. El cliente informa que pierde agua durante el ciclo de centrifugado.
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="integra-label">Estado de la Reparación (Tiempo Real)</div>
|
|
||||||
<div class="integra-tracker">
|
|
||||||
<div class="integra-step completed">Aviso recibido y validado (09:00)</div>
|
|
||||||
<div class="integra-step completed">Técnico asignado (09:15)</div>
|
|
||||||
<div class="integra-step active">Técnico de camino al domicilio (ETA: 15 min)</div>
|
|
||||||
<div class="integra-step">Reparación finalizada</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
</main>
|
</main>
|
||||||
|
|
||||||
|
<div id="newRequestModal" class="fixed inset-0 bg-slate-900/60 z-[100] hidden flex items-end sm:items-center justify-center backdrop-blur-sm sm:p-4">
|
||||||
|
<div class="bg-white w-full max-w-lg rounded-t-[2.5rem] sm:rounded-[2.5rem] shadow-2xl overflow-hidden flex flex-col fade-in max-h-[90vh]">
|
||||||
|
<div class="p-6 border-b border-slate-100 flex justify-between items-center sticky top-0 bg-white/90 backdrop-blur z-10">
|
||||||
|
<div>
|
||||||
|
<h3 class="font-black text-slate-800 uppercase tracking-tight text-lg">Nuevo Aviso</h3>
|
||||||
|
<p class="text-[10px] text-slate-400 font-bold uppercase tracking-widest mt-0.5">Envío directo a la central</p>
|
||||||
|
</div>
|
||||||
|
<button onclick="closeNewRequestModal()" class="bg-slate-100 text-slate-500 hover:text-red-500 p-2 rounded-full transition-colors active:scale-95"><i data-lucide="x" class="w-5 h-5"></i></button>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<form onsubmit="submitNewRequest(event)" class="p-6 overflow-y-auto no-scrollbar flex flex-col gap-5">
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label class="text-[10px] font-black uppercase tracking-widest text-slate-500 ml-1">Dirección de la avería</label>
|
||||||
|
<div class="relative">
|
||||||
|
<i data-lucide="map-pin" class="w-4 h-4 absolute left-4 top-4 text-slate-400"></i>
|
||||||
|
<input type="text" id="reqAddress" required placeholder="Ej: Calle Mayor 12, Piso 2A" class="w-full bg-slate-50 border border-slate-200 text-sm font-bold p-4 pl-11 rounded-[1.2rem] outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all text-slate-700 shadow-inner">
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="space-y-2">
|
||||||
|
<label class="text-[10px] font-black uppercase tracking-widest text-slate-500 ml-1">¿Qué ha ocurrido?</label>
|
||||||
|
<textarea id="reqDescription" required rows="4" placeholder="Explícanos brevemente qué se ha roto o qué necesitas..." class="w-full bg-slate-50 border border-slate-200 text-sm font-medium p-4 rounded-[1.2rem] outline-none focus:ring-2 focus:ring-blue-500 focus:border-blue-500 transition-all text-slate-700 shadow-inner resize-none"></textarea>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<button type="submit" id="btnSubmitRequest" class="w-full mt-2 bg-slate-900 text-white font-black py-4 rounded-[1.2rem] text-sm uppercase tracking-wider hover:bg-slate-800 transition-colors active:scale-95 shadow-lg flex justify-center items-center gap-2">
|
||||||
|
<i data-lucide="send" class="w-4 h-4"></i> Enviar Aviso Ahora
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div id="toast" class="fixed bottom-6 left-1/2 -translate-x-1/2 bg-slate-800 text-white px-6 py-3.5 rounded-full shadow-2xl hidden z-[200] font-bold text-sm flex items-center gap-3 transition-all transform whitespace-nowrap">
|
||||||
|
<i data-lucide="check-circle" class="w-4 h-4 text-emerald-400"></i>
|
||||||
|
<span id="toastMsg">Aviso enviado con éxito</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
// ==========================================
|
||||||
|
// ⚙️ CONFIGURACIÓN - ¡PON TU API AQUÍ!
|
||||||
|
// ==========================================
|
||||||
|
const API_URL = "http://tu-ip-o-dominio.com:3000"; // <--- CAMBIAR POR LA URL REAL DEL BACKEND
|
||||||
|
|
||||||
|
let clientData = null;
|
||||||
|
let apiToken = new URLSearchParams(window.location.search).get('token');
|
||||||
|
|
||||||
|
document.addEventListener("DOMContentLoaded", () => {
|
||||||
|
lucide.createIcons();
|
||||||
|
if (!apiToken) {
|
||||||
|
showError();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
loadPortalData();
|
||||||
|
});
|
||||||
|
|
||||||
|
async function loadPortalData() {
|
||||||
|
try {
|
||||||
|
const response = await fetch(`${API_URL}/public/portal/${apiToken}`);
|
||||||
|
const data = await response.json();
|
||||||
|
|
||||||
|
if (!data.ok) throw new Error("Invalid token");
|
||||||
|
|
||||||
|
clientData = data.client;
|
||||||
|
|
||||||
|
// Rellenar UI
|
||||||
|
document.getElementById('uiCompanyName').innerHTML = `<div class="w-2 h-2 bg-emerald-400 shadow-[0_0_8px_rgba(52,211,153,0.8)] rounded-full animate-pulse"></div> ${data.company.name}`;
|
||||||
|
document.getElementById('uiClientName').innerText = data.client.name.split(' ')[0]; // Solo el primer nombre
|
||||||
|
|
||||||
|
// Pre-rellenar formulario
|
||||||
|
if(data.client.addresses && data.client.addresses.length > 0) {
|
||||||
|
document.getElementById('reqAddress').value = data.client.addresses[0];
|
||||||
|
}
|
||||||
|
|
||||||
|
renderServices(data.services);
|
||||||
|
|
||||||
|
// Mostrar pantalla
|
||||||
|
document.getElementById('loader').classList.add('opacity-0');
|
||||||
|
setTimeout(() => {
|
||||||
|
document.getElementById('loader').classList.add('hidden');
|
||||||
|
document.getElementById('mainContent').classList.remove('hidden');
|
||||||
|
document.getElementById('mainContent').classList.add('flex');
|
||||||
|
}, 300);
|
||||||
|
|
||||||
|
} catch (error) {
|
||||||
|
console.error(error);
|
||||||
|
showError();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderServices(services) {
|
||||||
|
const container = document.getElementById('servicesContainer');
|
||||||
|
|
||||||
|
if (!services || services.length === 0) {
|
||||||
|
container.innerHTML = `
|
||||||
|
<div class="bg-white border-2 border-dashed border-slate-200 p-8 rounded-[2rem] text-center">
|
||||||
|
<div class="bg-slate-50 w-16 h-16 rounded-full flex items-center justify-center mx-auto mb-3">
|
||||||
|
<i data-lucide="inbox" class="w-8 h-8 text-slate-300"></i>
|
||||||
|
</div>
|
||||||
|
<h4 class="font-black text-slate-700 text-sm uppercase">Sin reparaciones</h4>
|
||||||
|
<p class="text-xs text-slate-400 mt-1">Aún no tienes historiales con nosotros.</p>
|
||||||
|
</div>`;
|
||||||
|
lucide.createIcons();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const colorMap = {
|
||||||
|
'gray': 'bg-slate-100 text-slate-600 border-slate-200',
|
||||||
|
'blue': 'bg-blue-100 text-blue-700 border-blue-200 shadow-[0_0_15px_rgba(59,130,246,0.15)]',
|
||||||
|
'emerald': 'bg-emerald-100 text-emerald-700 border-emerald-200 shadow-[0_0_15px_rgba(16,185,129,0.15)]',
|
||||||
|
'indigo': 'bg-indigo-100 text-indigo-700 border-indigo-200 shadow-[0_0_15px_rgba(99,102,241,0.15)]',
|
||||||
|
'amber': 'bg-amber-100 text-amber-700 border-amber-200 shadow-[0_0_15px_rgba(245,158,11,0.15)]',
|
||||||
|
'red': 'bg-rose-100 text-rose-700 border-rose-200',
|
||||||
|
'purple': 'bg-purple-100 text-purple-700 border-purple-200'
|
||||||
|
};
|
||||||
|
|
||||||
|
const iconMap = {
|
||||||
|
'gray': 'clock',
|
||||||
|
'blue': 'user-check',
|
||||||
|
'emerald': 'calendar-check',
|
||||||
|
'indigo': 'car',
|
||||||
|
'amber': 'wrench',
|
||||||
|
'red': 'alert-triangle',
|
||||||
|
'purple': 'check-circle'
|
||||||
|
};
|
||||||
|
|
||||||
|
container.innerHTML = services.map(s => {
|
||||||
|
const badgeClass = colorMap[s.status_color] || colorMap['gray'];
|
||||||
|
const badgeIcon = iconMap[s.status_color] || 'info';
|
||||||
|
|
||||||
|
const fechaCita = s.scheduled_date ? `<div class="flex items-center gap-1.5 text-xs font-bold text-slate-600 bg-slate-50 px-3 py-1.5 rounded-lg border border-slate-100"><i data-lucide="calendar" class="w-3.5 h-3.5 text-slate-400"></i> ${s.scheduled_date} ${s.scheduled_time ? `| ${s.scheduled_time}` : ''}</div>` : '';
|
||||||
|
|
||||||
|
const tecnico = s.assigned_worker !== "Pendiente" ? `<div class="flex items-center gap-1.5 text-[10px] font-black uppercase text-slate-500 mt-3 pt-3 border-t border-slate-100"><i data-lucide="hard-hat" class="w-3.5 h-3.5"></i> Técnico: ${s.assigned_worker}</div>` : '';
|
||||||
|
|
||||||
|
return `
|
||||||
|
<div class="bg-white p-5 rounded-[1.5rem] shadow-sm border border-slate-200 flex flex-col gap-3 relative overflow-hidden">
|
||||||
|
${s.status_color !== 'purple' && s.status_color !== 'red' && s.status_color !== 'gray' ? `<div class="absolute top-0 left-0 w-1 h-full bg-${s.status_color}-500"></div>` : ''}
|
||||||
|
|
||||||
|
<div class="flex justify-between items-start gap-2">
|
||||||
|
<div class="${badgeClass} px-3 py-1.5 rounded-xl border flex items-center gap-1.5 w-max">
|
||||||
|
<i data-lucide="${badgeIcon}" class="w-3.5 h-3.5"></i>
|
||||||
|
<span class="text-[10px] font-black uppercase tracking-wider">${s.status_name}</span>
|
||||||
|
</div>
|
||||||
|
<span class="text-[9px] font-black text-slate-300 uppercase tracking-widest bg-slate-50 px-2 py-1 rounded-md border border-slate-100">${s.title}</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<p class="text-sm font-medium text-slate-700 leading-snug mt-1">${s.description.replace(/\n/g, '<br>')}</p>
|
||||||
|
|
||||||
|
${fechaCita}
|
||||||
|
${tecnico}
|
||||||
|
</div>`;
|
||||||
|
}).join('');
|
||||||
|
|
||||||
|
lucide.createIcons();
|
||||||
|
}
|
||||||
|
|
||||||
|
async function submitNewRequest(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
const btn = document.getElementById('btnSubmitRequest');
|
||||||
|
const originalContent = btn.innerHTML;
|
||||||
|
const address = document.getElementById('reqAddress').value;
|
||||||
|
const desc = document.getElementById('reqDescription').value;
|
||||||
|
|
||||||
|
btn.innerHTML = `<i data-lucide="loader-2" class="w-4 h-4 animate-spin"></i> Procesando...`;
|
||||||
|
btn.disabled = true;
|
||||||
|
|
||||||
|
try {
|
||||||
|
const res = await fetch(`${API_URL}/public/portal/${apiToken}/request`, {
|
||||||
|
method: 'POST',
|
||||||
|
headers: { 'Content-Type': 'application/json' },
|
||||||
|
body: JSON.stringify({ address: address, description: desc })
|
||||||
|
});
|
||||||
|
|
||||||
|
if(res.ok) {
|
||||||
|
closeNewRequestModal();
|
||||||
|
document.getElementById('reqDescription').value = ""; // limpiar
|
||||||
|
showToast();
|
||||||
|
loadPortalData(); // Recargar para mostrar la nueva petición
|
||||||
|
} else {
|
||||||
|
alert("Error al enviar el aviso. Inténtalo de nuevo.");
|
||||||
|
}
|
||||||
|
} catch (error) {
|
||||||
|
alert("Error de conexión con el servidor.");
|
||||||
|
} finally {
|
||||||
|
btn.innerHTML = originalContent;
|
||||||
|
btn.disabled = false;
|
||||||
|
lucide.createIcons();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function showError() {
|
||||||
|
document.getElementById('loader').classList.add('hidden');
|
||||||
|
document.getElementById('errorScreen').classList.remove('hidden');
|
||||||
|
document.getElementById('errorScreen').classList.add('flex');
|
||||||
|
}
|
||||||
|
|
||||||
|
function openNewRequestModal() {
|
||||||
|
document.getElementById('newRequestModal').classList.remove('hidden');
|
||||||
|
document.body.style.overflow = 'hidden'; // Evitar scroll de fondo en móvil
|
||||||
|
}
|
||||||
|
|
||||||
|
function closeNewRequestModal() {
|
||||||
|
document.getElementById('newRequestModal').classList.add('hidden');
|
||||||
|
document.body.style.overflow = '';
|
||||||
|
}
|
||||||
|
|
||||||
|
function showToast() {
|
||||||
|
const t = document.getElementById('toast');
|
||||||
|
t.classList.remove('hidden');
|
||||||
|
setTimeout(() => { t.classList.add('translate-y-[-20px]', 'opacity-0'); }, 3000);
|
||||||
|
setTimeout(() => {
|
||||||
|
t.classList.add('hidden');
|
||||||
|
t.classList.remove('translate-y-[-20px]', 'opacity-0');
|
||||||
|
}, 3500);
|
||||||
|
}
|
||||||
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
Reference in New Issue
Block a user