diff --git a/frontend/src/pages/Asesores.jsx b/frontend/src/pages/Asesores.jsx
index 5e739a3..2c2be4a 100644
--- a/frontend/src/pages/Asesores.jsx
+++ b/frontend/src/pages/Asesores.jsx
@@ -1,8 +1,12 @@
// src/pages/Asesores.jsx
-import { useState, useEffect, useCallback } from "react";
+import { useState, useEffect, useCallback, Fragment } from "react";
import { api } from "../lib/api";
import { Loader, ErrorBox } from "../components/UI";
+const MES_LARGO = ["Enero","Febrero","Marzo","Abril","Mayo","Junio","Julio","Agosto","Septiembre","Octubre","Noviembre","Diciembre"];
+const MES_CORTO = ["Ene","Feb","Mar","Abr","May","Jun","Jul","Ago","Sep","Oct","Nov","Dic"];
+const calNavBtn = { width:26, height:26, borderRadius:7, border:"1px solid #e2e8f0", background:"#f8fafc", cursor:"pointer", fontSize:13, color:"#475569" };
+
const ESTADO_INFO = {
online: { txt: "En Línea", color: "#10b981", bg: "#d1fae5", fg: "#065f46" },
busy: { txt: "Ocupado", color: "#f59e0b", bg: "#fef9c3", fg: "#854d0e" },
@@ -17,11 +21,47 @@ export default function Asesores() {
const [histAsesor, setHistAsesor] = useState(null); // { nombre, email }
const [histFilas, setHistFilas] = useState([]);
const [histLoading, setHistLoading] = useState(false);
+ const [semanaBase, setSemanaBase] = useState(null); // Date del lunes de la semana mostrada
+ const [calAbierto, setCalAbierto] = useState(false); // popover del mini-calendario
+ const [calVista, setCalVista] = useState("dias"); // "dias" | "meses" | "anios"
+ const [calAno, setCalAno] = useState(new Date().getFullYear());
+ const [calMes, setCalMes] = useState(new Date().getMonth());
+ const [histVista, setHistVista] = useState("calendario"); // "calendario" | "lista"
+ const [listaDia, setListaDia] = useState(""); // filtro día en vista lista (YYYY-MM-DD)
+ const [listaCalAbierto, setListaCalAbierto] = useState(false);
+ const [listaCalVista, setListaCalVista] = useState("dias");
+ const [listaCalAno, setListaCalAno] = useState(new Date().getFullYear());
+ const [listaCalMes, setListaCalMes] = useState(new Date().getMonth());
+
+ // Lunes de la semana que contiene la fecha dada.
+ const lunesDe = (d) => {
+ const x = new Date(d);
+ const dia = (x.getDay() + 6) % 7; // 0=lunes ... 6=domingo
+ x.setHours(0, 0, 0, 0);
+ x.setDate(x.getDate() - dia);
+ return x;
+ };
+
+ // Eventos ordenados de más antiguo a más reciente.
+ const histOrden = histFilas.slice()
+ .sort((a, b) => (a.fecha_hora || "").localeCompare(b.fecha_hora || ""));
+
+ // Intervalos "estuvo conectado" [desde, hasta, enCurso] a partir de los ON/OFF.
+ const intervalosON = (() => {
+ const out = [];
+ let ini = null;
+ for (const h of histOrden) {
+ if (h.accion === "ON" && !ini) ini = new Date(h.fecha_hora);
+ else if (h.accion === "OFF" && ini) { out.push([ini, new Date(h.fecha_hora), false]); ini = null; }
+ }
+ if (ini) out.push([ini, new Date(), true]); // sigue conectado hasta ahora (en curso)
+ return out;
+ })();
async function verHistorial(ag) {
const nombre = ag.name || ag.available_name || "—";
setHistAsesor({ nombre, email: ag.email });
- setHistFilas([]); setHistLoading(true);
+ setHistFilas([]); setSemanaBase(lunesDe(new Date())); setHistLoading(true);
try {
const r = await api.asesorHistorial(ag.email);
setHistFilas(r.historial || []);
@@ -117,6 +157,21 @@ export default function Asesores() {
{ag.email || "—"}
+ {/* Auto-offline (solo lectura) */}
+ {(() => {
+ const ao = ag.auto_offline === true || ag.auto_offline === "true";
+ return (
+
+
+ Auto-offline: {ao ? "ON" : "OFF"}
+
+ );
+ })()}
{/* Historial */}