Rediseño visual de becario.html (piel cream) sobre theme.js
Reconstruye el portal del becario con el lenguaje visual del diseño (paleta crema, tipografías Bricolage Grotesque/Figtree, íconos de línea, logo de la Fundación) sin tocar la lógica ni el cableado al backend. theme.js: - El set "cream" ahora también atiende el flavor 'becario' (móvil, igual que checada). Añade StatusBadge (mapea el estado real al color), HorasCard (barra de avance + variante "¡Meta cumplida!" con estrella), la variante 'success' de Aviso, el Btn 'ghost', los íconos star/calendar y el tono neutral. El camino de panel queda intacto (COLORS/FONT). becario.html: - Migra login/registro y portal a los componentes cream. Los ~14 estados del inventario se conservan y cada uno se dispara por su MISMO code/estado (429, TELEFONO_YA_REGISTRADO, motivo de registro 4xx, pendiente, meta al 100%, jornadas vacío/lista, solicitud enviada…). Endpoints, campos (telefono/password/nombre/entrada_ts), guardia de sesión y el cálculo de horas en el backend sin cambios. - Copy más claro: una jornada sin salida muestra "sin salida" (no "abierta", que chocaba con el badge); el campo de olvido lleva label "Fecha y hora de entrada". Sin marcos de iPhone ni barra de estado. checada.html y panel.html quedan byte-idénticos.
This commit is contained in:
1 parent
fbf4e7d78d
commit
2e72187c5d
2 files changed
+231
-95
No files matched your search
+152
-78
@@ -4,16 +4,27 @@
|
||||
<meta charset="UTF-8"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
|
||||
<title>Taboada — Mis horas</title>
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com"/>
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin/>
|
||||
<link href="https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,600;12..96,700&family=Figtree:wght@400;500;600;700&display=swap" rel="stylesheet"/>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/18.2.0/umd/react.production.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/18.2.0/umd/react-dom.production.min.js"></script>
|
||||
<script src="https://cdnjs.cloudflare.com/ajax/libs/babel-standalone/7.23.2/babel.min.js"></script>
|
||||
<script src="theme.js"></script>
|
||||
<style>
|
||||
* { box-sizing: border-box; }
|
||||
html, body { margin: 0; padding: 0; }
|
||||
body { background: #F3EBDD; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; }
|
||||
input::placeholder { color: #B4A99A; }
|
||||
@keyframes tb-spin { to { transform: rotate(360deg); } }
|
||||
</style>
|
||||
</head>
|
||||
<body style="margin:0;padding:0;">
|
||||
<body>
|
||||
<div id="root"></div>
|
||||
<script type="text/babel" data-presets="react">
|
||||
const { useState, useEffect, useCallback } = React;
|
||||
|
||||
// ─────────────────── Cableado al backend (SIN cambios) ───────────────────
|
||||
const API_BASE = `${window.location.origin}/api`;
|
||||
async function apiFetch(path, options = {}) {
|
||||
const res = await fetch(`${API_BASE}${path}`, {
|
||||
@@ -30,9 +41,10 @@ async function apiFetch(path, options = {}) {
|
||||
return data;
|
||||
}
|
||||
|
||||
// Base visual compartida (theme.js), ligada al flavor 'becario'.
|
||||
const { COLORS, FONT, SPACE, RADIUS, makeUI } = Theme;
|
||||
const { Btn, Card, Input, Badge, Field, Estado } = makeUI("becario");
|
||||
// Piel visual "cream" del rediseño, servida por theme.js (flavor 'becario' =
|
||||
// móvil, mismos componentes y tokens que checada). Nada de colores inline.
|
||||
const UI = Theme.makeUI("becario");
|
||||
const { Logo, Card, Btn, Input, Aviso, IconBadge, StatusBadge, HorasCard, palette, fonts, icons } = UI;
|
||||
|
||||
function fmtDT(iso) {
|
||||
if (!iso) return "—";
|
||||
@@ -43,17 +55,43 @@ function fmtDT(iso) {
|
||||
const fmtHoras = (h) => `${(h ?? 0).toLocaleString("es-MX", { maximumFractionDigits: 1 })} h`;
|
||||
function localToIso(v) { return v ? new Date(v).toISOString() : null; }
|
||||
|
||||
const ErrorBar = ({ error, onClose }) => !error ? null : (
|
||||
<div style={{ background: COLORS.dangerBg, color: COLORS.danger, padding: "10px 14px", borderRadius: "10px", fontSize: "14px", marginBottom: "12px", display: "flex", justifyContent: "space-between" }}>
|
||||
<span>⚠ {error}</span><span onClick={onClose} style={{ cursor: "pointer", fontWeight: 700 }}>✕</span>
|
||||
// ─────────────────── Piezas visuales locales ───────────────────
|
||||
const Cargando = ({ texto = "Cargando…" }) => (
|
||||
<div style={{ minHeight: "100vh", background: palette.bgGradient, display: "grid", placeItems: "center", fontFamily: fonts.body }}>
|
||||
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "12px", color: palette.inkSoft }}>
|
||||
<span style={{ display: "inline-flex" }}>{icons.spinner({ size: 24, color: palette.primary, track: palette.line })}</span>
|
||||
<span style={{ fontFamily: fonts.body, fontSize: "14px" }}>{texto}</span>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
// ═══════════════ Login / Registro ═══════════════
|
||||
// Header de marca para la pantalla de acceso (logo con las mismas proporciones
|
||||
// que checada, + wordmark y subtítulo del diseño).
|
||||
const Marca = () => (
|
||||
<div style={{ textAlign: "center", marginBottom: "18px" }}>
|
||||
<div style={{ display: "flex", justifyContent: "center", marginBottom: "10px" }}><Logo /></div>
|
||||
<h1 style={{ margin: "0 0 3px", fontFamily: fonts.title, fontWeight: 600, fontSize: "24px", color: palette.brand, letterSpacing: "-.01em" }}>Taboada</h1>
|
||||
<p style={{ margin: 0, fontFamily: fonts.body, fontSize: "13px", color: palette.inkSoft }}>Registro de horas de servicio</p>
|
||||
</div>
|
||||
);
|
||||
|
||||
// Barra de error global, descartable (estado P8 del inventario).
|
||||
const ErrorBar = ({ error, onClose }) => !error ? null : (
|
||||
<div style={{ display: "flex", alignItems: "center", justifyContent: "space-between", gap: "10px",
|
||||
background: palette.errBg, border: `1px solid ${palette.errBorder}`, borderRadius: "14px", padding: "12px 14px", marginBottom: "16px" }}>
|
||||
<span style={{ display: "flex", alignItems: "center", gap: "9px" }}>
|
||||
<span style={{ display: "inline-flex", flexShrink: 0 }}>{icons.alertTriangle({ size: 18, color: palette.danger })}</span>
|
||||
<span style={{ fontFamily: fonts.body, fontSize: "13px", fontWeight: 500, color: palette.errText, lineHeight: 1.35 }}>{error}</span>
|
||||
</span>
|
||||
<span onClick={onClose} style={{ cursor: "pointer", flexShrink: 0, fontWeight: 700, color: palette.errText, fontSize: "16px", lineHeight: 1, padding: "0 2px" }}>✕</span>
|
||||
</div>
|
||||
);
|
||||
|
||||
// ═══════════════ Acceso · login / registro ═══════════════
|
||||
function Acceso({ onEntra }) {
|
||||
const [modo, setModo] = useState("login");
|
||||
const [f, setF] = useState({ telefono: "", password: "", nombre: "" });
|
||||
const [error, setError] = useState(null);
|
||||
const [error, setError] = useState(null); // { text, ic }
|
||||
const [busy, setBusy] = useState(false);
|
||||
const set = (k) => (e) => setF({ ...f, [k]: k === "telefono" ? e.target.value.replace(/\D/g, "").slice(0, 10) : e.target.value });
|
||||
const submit = async (e) => {
|
||||
@@ -66,34 +104,36 @@ function Acceso({ onEntra }) {
|
||||
}
|
||||
onEntra(await apiFetch("/becario/session"));
|
||||
} catch (err) {
|
||||
let msg;
|
||||
if (err.status === 429) msg = "Demasiados intentos, espera un minuto.";
|
||||
else if (err.code === "TELEFONO_YA_REGISTRADO") msg = "Ese número ya está registrado. Inicia sesión.";
|
||||
// Mismo mapeo por code/status de siempre; el ícono sólo acompaña.
|
||||
let text, ic = "alertCircle";
|
||||
if (err.status === 429) { text = "Demasiados intentos, espera un minuto."; ic = "clock"; }
|
||||
else if (err.code === "TELEFONO_YA_REGISTRADO") text = "Ese número ya está registrado. Inicia sesión.";
|
||||
// Motivo específico del backend para errores de datos (4xx): teléfono,
|
||||
// contraseña corta, nombre. No se muestra el detalle de errores 5xx.
|
||||
else if (modo === "registro" && err.status >= 400 && err.status < 500 && err.message) msg = err.message;
|
||||
else if (modo === "registro") msg = "No se pudo registrar. Intenta de nuevo.";
|
||||
else msg = "Número o contraseña incorrectos.";
|
||||
setError(msg);
|
||||
else if (modo === "registro" && err.status >= 400 && err.status < 500 && err.message) text = err.message;
|
||||
else if (modo === "registro") text = "No se pudo registrar. Intenta de nuevo.";
|
||||
else text = "Número o contraseña incorrectos.";
|
||||
setError({ text, ic });
|
||||
} finally { setBusy(false); }
|
||||
};
|
||||
const reg = modo === "registro";
|
||||
return (
|
||||
<div style={{ minHeight: "100vh", background: COLORS.bg, display: "flex", alignItems: "center", justifyContent: "center", padding: "20px", fontFamily: FONT }}>
|
||||
<div style={{ width: "100%", maxWidth: "380px" }}>
|
||||
<h1 style={{ textAlign: "center", color: COLORS.ink, fontSize: "24px", marginBottom: "4px" }}>Taboada</h1>
|
||||
<p style={{ textAlign: "center", color: COLORS.inkSoft, marginTop: 0, marginBottom: "18px" }}>Registro de horas de servicio</p>
|
||||
<div style={{ minHeight: "100vh", background: palette.bgGradient, display: "flex", flexDirection: "column", justifyContent: "center", padding: "32px 20px", fontFamily: fonts.body }}>
|
||||
<div style={{ width: "100%", maxWidth: "420px", margin: "0 auto" }}>
|
||||
<Marca />
|
||||
<Card>
|
||||
<div style={{ display: "flex", gap: "8px", marginBottom: "16px" }}>
|
||||
<div style={{ display: "flex", gap: "7px", background: palette.softTint, borderRadius: "13px", padding: "4px", marginBottom: "18px" }}>
|
||||
{["login", "registro"].map((m) => (
|
||||
<button key={m} onClick={() => { setModo(m); setError(null); }} style={{
|
||||
flex: 1, padding: "9px", borderRadius: "9px", border: "none", cursor: "pointer", fontFamily: FONT, fontWeight: 700, fontSize: "14px",
|
||||
background: modo === m ? COLORS.primary : COLORS.chip, color: modo === m ? "#fff" : COLORS.inkSoft,
|
||||
<button key={m} type="button" onClick={() => { setModo(m); setError(null); }} style={{
|
||||
flex: 1, textAlign: "center", padding: "9px", borderRadius: "10px", border: "none", cursor: "pointer",
|
||||
fontFamily: fonts.body, fontWeight: 700, fontSize: "14px",
|
||||
background: modo === m ? palette.primary : "transparent", color: modo === m ? "#fff" : palette.inkSoft,
|
||||
}}>{m === "login" ? "Entrar" : "Registrarme"}</button>
|
||||
))}
|
||||
</div>
|
||||
<ErrorBar error={error} onClose={() => setError(null)} />
|
||||
{error && <Aviso variant="error" icon={error.ic}>{error.text}</Aviso>}
|
||||
<form onSubmit={submit}>
|
||||
{modo === "registro" && (
|
||||
{reg && (
|
||||
<div style={{ marginBottom: "12px" }}>
|
||||
<Input placeholder="Tu nombre" value={f.nombre} onChange={set("nombre")} required />
|
||||
</div>
|
||||
@@ -101,16 +141,18 @@ function Acceso({ onEntra }) {
|
||||
<div style={{ marginBottom: "12px" }}>
|
||||
<Input placeholder="Celular (10 dígitos)" inputMode="numeric" value={f.telefono} onChange={set("telefono")} required />
|
||||
</div>
|
||||
<div style={{ marginBottom: "16px" }}>
|
||||
<div style={{ marginBottom: "18px" }}>
|
||||
<Input type="password" placeholder="Contraseña" value={f.password} onChange={set("password")} required />
|
||||
</div>
|
||||
<Btn type="submit" disabled={busy || f.telefono.length !== 10 || f.password.length < (modo === "registro" ? 6 : 1) || (modo === "registro" && !f.nombre.trim())}>
|
||||
{busy ? "…" : modo === "registro" ? "Crear cuenta" : "Entrar"}
|
||||
<Btn type="submit" loading={busy} disabled={busy || f.telefono.length !== 10 || f.password.length < (reg ? 6 : 1) || (reg && !f.nombre.trim())}>
|
||||
{busy ? (reg ? "Creando…" : "Entrando…") : (reg ? "Crear cuenta" : "Entrar")}
|
||||
</Btn>
|
||||
</form>
|
||||
{modo === "registro" && <p style={{ fontSize: "12px", color: COLORS.inkSoft, marginTop: "12px", marginBottom: 0, textAlign: "center" }}>
|
||||
Tu cuenta queda pendiente hasta que la supervisora la apruebe.
|
||||
</p>}
|
||||
{reg && (
|
||||
<p style={{ margin: "12px 0 0", fontFamily: fonts.body, fontSize: "12px", color: palette.inkSoft, textAlign: "center", lineHeight: 1.5 }}>
|
||||
Tu cuenta queda pendiente hasta que la supervisora la apruebe.
|
||||
</p>
|
||||
)}
|
||||
</Card>
|
||||
</div>
|
||||
</div>
|
||||
@@ -147,68 +189,100 @@ function Portal({ session, onSalir }) {
|
||||
} catch (err) { setError(err.message); } finally { setEnviando(false); }
|
||||
};
|
||||
|
||||
if (!resumen) return <div style={{ minHeight: "100vh", display: "grid", placeItems: "center", fontFamily: FONT, color: COLORS.inkSoft }}>Cargando…</div>;
|
||||
if (!resumen) return <Cargando texto="Cargando tu portal…" />;
|
||||
// Horas y avance vienen calculados del backend (resumen.horas); aquí sólo se pintan.
|
||||
const h = resumen.horas;
|
||||
const pendiente = resumen.estado === "pendiente";
|
||||
const meta = h.porcentaje >= 100;
|
||||
const secTitle = { margin: "20px 0 9px", fontFamily: fonts.title, fontWeight: 600, fontSize: "15px", color: palette.brand };
|
||||
|
||||
return (
|
||||
<div style={{ minHeight: "100vh", background: COLORS.bg, fontFamily: FONT }}>
|
||||
<header style={{ background: COLORS.surface, borderBottom: `1px solid ${COLORS.border}`, padding: "14px 18px", display: "flex", justifyContent: "space-between", alignItems: "center" }}>
|
||||
<div style={{ minHeight: "100vh", background: palette.bgGradient, fontFamily: fonts.body }}>
|
||||
<header style={{ maxWidth: "440px", margin: "0 auto", padding: "16px 18px 14px", display: "flex", justifyContent: "space-between", alignItems: "center", borderBottom: `1px solid ${palette.cardBorder}` }}>
|
||||
<div>
|
||||
<div style={{ fontWeight: 700, color: COLORS.ink }}>{resumen.nombre}</div>
|
||||
<div style={{ fontSize: "12px", color: COLORS.inkSoft }}>{resumen.telefono} · <Badge tone={resumen.estado}>{resumen.estado}</Badge></div>
|
||||
<div style={{ fontFamily: fonts.body, fontWeight: 600, fontSize: "15px", color: palette.brand }}>{resumen.nombre}</div>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "6px", marginTop: "2px", fontFamily: fonts.body, fontSize: "12px", color: palette.inkSoft }}>
|
||||
{resumen.telefono} <StatusBadge tone={resumen.estado}>{resumen.estado}</StatusBadge>
|
||||
</div>
|
||||
</div>
|
||||
<button onClick={salir} style={{ background: "none", border: `1px solid ${COLORS.border}`, borderRadius: "8px", padding: "8px 12px", color: COLORS.primary, fontFamily: FONT, fontWeight: 600, cursor: "pointer" }}>Salir</button>
|
||||
<button onClick={salir} style={{ padding: "7px 12px", background: "transparent", border: `1px solid ${palette.line}`, borderRadius: "11px", fontFamily: fonts.body, fontWeight: 600, fontSize: "12px", color: palette.primary, cursor: "pointer" }}>Salir</button>
|
||||
</header>
|
||||
<main style={{ maxWidth: "460px", margin: "0 auto", padding: "18px" }}>
|
||||
|
||||
<main style={{ maxWidth: "440px", margin: "0 auto", padding: "18px" }}>
|
||||
<ErrorBar error={error} onClose={() => setError(null)} />
|
||||
|
||||
{pendiente && (
|
||||
<Card style={{ background: COLORS.warnBg, borderColor: COLORS.warn }}>
|
||||
<strong style={{ color: COLORS.warn }}>Cuenta pendiente de aprobación</strong>
|
||||
<p style={{ margin: "6px 0 0", fontSize: "14px", color: COLORS.ink }}>Ya puedes ver tu portal, pero aún no puedes checar. Avisa a la supervisora para que apruebe tu cuenta.</p>
|
||||
<div style={{ background: palette.warnBg, border: `1px solid ${palette.warnBorder}`, borderRadius: "18px", padding: "16px 18px", marginBottom: "18px" }}>
|
||||
<div style={{ display: "flex", alignItems: "center", gap: "8px", marginBottom: "6px" }}>
|
||||
<span style={{ display: "inline-flex", flexShrink: 0 }}>{icons.clock({ size: 17, color: palette.amber })}</span>
|
||||
<strong style={{ fontFamily: fonts.body, fontWeight: 600, fontSize: "14px", color: palette.warnText }}>Cuenta pendiente de aprobación</strong>
|
||||
</div>
|
||||
<p style={{ margin: 0, fontFamily: fonts.body, fontSize: "13px", color: palette.warnText, lineHeight: 1.5 }}>
|
||||
Ya puedes ver tu portal, pero aún no puedes checar. Avisa a la supervisora para que apruebe tu cuenta.
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<HorasCard
|
||||
total={fmtHoras(h.total_horas)} meta={fmtHoras(h.meta_horas)} porcentaje={h.porcentaje}
|
||||
sub={`${h.porcentaje}% de tu meta · jornadas ${(h.minutos_jornadas / 60).toFixed(1)} h + ajustes ${(h.minutos_ajustes / 60).toFixed(1)} h`}
|
||||
/>
|
||||
|
||||
{meta && (
|
||||
<div style={{ marginTop: "16px" }}>
|
||||
<Aviso variant="success">Completaste tus horas de servicio social. La supervisora recibirá la constancia para tu liberación. ¡Gracias por tu compromiso!</Aviso>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<h3 style={secTitle}>Mis jornadas</h3>
|
||||
{jornadas.length === 0 ? (
|
||||
<Card style={{ textAlign: "center", padding: "26px 20px" }}>
|
||||
<IconBadge icon="calendar" tone="neutral" size={52} />
|
||||
<p style={{ margin: 0, fontFamily: fonts.body, fontSize: "13px", color: palette.inkSoft, lineHeight: 1.5 }}>
|
||||
Aún no tienes jornadas.<br/>Empezarán a aparecer cuando puedas checar.
|
||||
</p>
|
||||
</Card>
|
||||
) : (
|
||||
<Card style={{ padding: 0, borderRadius: "18px", overflow: "hidden" }}>
|
||||
{jornadas.slice(0, 20).map((j, i, arr) => (
|
||||
<div key={j.id} style={{ display: "flex", justifyContent: "space-between", alignItems: "center", padding: "12px 15px", borderBottom: i < arr.length - 1 ? `1px solid ${palette.line}` : "none" }}>
|
||||
<div>
|
||||
<div style={{ fontFamily: fonts.body, fontWeight: 500, fontSize: "13px", color: palette.ink }}>
|
||||
{fmtDT(j.entrada_ts)} → {j.salida_ts ? fmtDT(j.salida_ts) : "sin salida"}
|
||||
</div>
|
||||
<div style={{ fontFamily: fonts.body, fontWeight: 400, fontSize: "11px", color: palette.inkSoft, marginTop: "2px" }}>
|
||||
{j.estado}{j.duracion_minutos != null ? ` · ${(j.duracion_minutos / 60).toFixed(1)} h` : ""}
|
||||
</div>
|
||||
</div>
|
||||
<StatusBadge tone={j.estado}>{j.estado}</StatusBadge>
|
||||
</div>
|
||||
))}
|
||||
</Card>
|
||||
)}
|
||||
|
||||
<Card>
|
||||
<div style={{ fontSize: "13px", color: COLORS.inkSoft, marginBottom: "4px" }}>Horas acumuladas</div>
|
||||
<div style={{ fontSize: "30px", fontWeight: 800, color: COLORS.ink }}>
|
||||
{fmtHoras(h.total_horas)} <span style={{ fontSize: "15px", fontWeight: 500, color: COLORS.inkSoft }}>de {fmtHoras(h.meta_horas)}</span>
|
||||
</div>
|
||||
<div style={{ height: "9px", background: COLORS.chip, borderRadius: "999px", overflow: "hidden", margin: "12px 0 6px" }}>
|
||||
<div style={{ height: "100%", width: `${Math.min(100, h.porcentaje)}%`, background: h.porcentaje >= 100 ? COLORS.success : COLORS.primary }} />
|
||||
</div>
|
||||
<div style={{ fontSize: "13px", color: COLORS.inkSoft }}>{h.porcentaje}% de tu meta · jornadas {(h.minutos_jornadas / 60).toFixed(1)} h + ajustes {(h.minutos_ajustes / 60).toFixed(1)} h</div>
|
||||
</Card>
|
||||
|
||||
<h3 style={{ fontSize: "15px", color: COLORS.ink, margin: "18px 0 8px" }}>Mis jornadas</h3>
|
||||
{jornadas.length === 0 ? <Card><span style={{ color: COLORS.inkSoft }}>Aún no tienes jornadas.</span></Card> :
|
||||
<Card style={{ padding: "6px 0" }}>
|
||||
{jornadas.slice(0, 20).map((j) => (
|
||||
<div key={j.id} style={{ display: "flex", justifyContent: "space-between", alignItems: "center", padding: "10px 16px", borderBottom: `1px solid ${COLORS.chip}` }}>
|
||||
<div style={{ fontSize: "14px", color: COLORS.ink }}>
|
||||
{fmtDT(j.entrada_ts)} → {j.salida_ts ? fmtDT(j.salida_ts) : "abierta"}
|
||||
<div style={{ fontSize: "12px", color: COLORS.inkSoft }}>{j.estado}{j.duracion_minutos != null ? ` · ${(j.duracion_minutos / 60).toFixed(1)} h` : ""}</div>
|
||||
</div>
|
||||
<Badge tone={j.estado === "cerrada" ? "activo" : j.estado === "revision" ? "pendiente" : "baja"}>{j.estado}</Badge>
|
||||
</div>
|
||||
))}
|
||||
</Card>}
|
||||
|
||||
<h3 style={{ fontSize: "15px", color: COLORS.ink, margin: "18px 0 8px" }}>Olvidé marcar mi entrada</h3>
|
||||
<Card>
|
||||
<p style={{ margin: "0 0 10px", fontSize: "13px", color: COLORS.inkSoft }}>Propón la hora a la que entraste; la supervisora la revisará y autorizará.</p>
|
||||
<h3 style={secTitle}>Olvidé marcar mi entrada</h3>
|
||||
<Card style={{ borderRadius: "18px", padding: "18px" }}>
|
||||
<p style={{ margin: "0 0 11px", fontFamily: fonts.body, fontSize: "13px", color: palette.inkSoft, lineHeight: 1.5 }}>
|
||||
Propón la hora a la que entraste; la supervisora la revisará y autorizará.
|
||||
</p>
|
||||
<form onSubmit={crearSolicitud}>
|
||||
<div style={{ marginBottom: "10px" }}>
|
||||
<label style={{ display: "block", fontFamily: fonts.body, fontSize: "12px", fontWeight: 600, color: palette.label, marginBottom: "6px" }}>Fecha y hora de entrada</label>
|
||||
<div style={{ marginBottom: "12px" }}>
|
||||
<Input type="datetime-local" value={entradaTs} onChange={(e) => setEntradaTs(e.target.value)} required />
|
||||
</div>
|
||||
{okMsg && <p style={{ color: COLORS.success, fontSize: "13px", margin: "0 0 10px" }}>✓ {okMsg}</p>}
|
||||
<Btn type="submit" variant="ghost" disabled={enviando || !entradaTs}>{enviando ? "Enviando…" : "Enviar solicitud"}</Btn>
|
||||
{okMsg && <Aviso variant="success" icon="check">{okMsg}</Aviso>}
|
||||
<Btn type="submit" variant="ghost" loading={enviando} disabled={enviando || !entradaTs}>
|
||||
{enviando ? "Enviando…" : "Enviar solicitud"}
|
||||
</Btn>
|
||||
</form>
|
||||
{solicitudes.length > 0 && (
|
||||
<div style={{ marginTop: "14px" }}>
|
||||
<div style={{ marginTop: "14px", borderTop: `1px solid ${palette.line}`, paddingTop: "6px" }}>
|
||||
{solicitudes.slice(0, 5).map((s) => (
|
||||
<div key={s.id} style={{ display: "flex", justifyContent: "space-between", fontSize: "13px", padding: "6px 0", color: COLORS.inkSoft }}>
|
||||
<span>{s.tipo === "olvido_entrada" ? "Olvido de entrada" : "Auto-cierre"} · {fmtDT(s.propuesta?.entrada_ts || s.created_at)}</span>
|
||||
<Badge tone={s.estado === "autorizada" ? "activo" : s.estado === "rechazada" ? "baja" : "pendiente"}>{s.estado}</Badge>
|
||||
<div key={s.id} style={{ display: "flex", justifyContent: "space-between", alignItems: "center", padding: "9px 0" }}>
|
||||
<span style={{ fontFamily: fonts.body, fontSize: "12px", color: palette.inkSoft }}>
|
||||
{s.tipo === "olvido_entrada" ? "Olvido de entrada" : "Auto-cierre"} · {fmtDT(s.propuesta?.entrada_ts || s.created_at)}
|
||||
</span>
|
||||
<StatusBadge tone={s.estado}>{s.estado}</StatusBadge>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
@@ -223,7 +297,7 @@ function Portal({ session, onSalir }) {
|
||||
function App() {
|
||||
const [session, setSession] = useState(undefined);
|
||||
useEffect(() => { apiFetch("/becario/session").then(setSession).catch(() => setSession(null)); }, []);
|
||||
if (session === undefined) return <div style={{ minHeight: "100vh", display: "grid", placeItems: "center", fontFamily: FONT, color: COLORS.inkSoft }}>Cargando…</div>;
|
||||
if (session === undefined) return <Cargando texto="Verificando sesión…" />;
|
||||
if (!session) return <Acceso onEntra={setSession} />;
|
||||
return <Portal session={session} onSalir={() => setSession(null)} />;
|
||||
}
|
||||
|
||||
+79
-17
@@ -26,8 +26,8 @@ window.Theme = (function () {
|
||||
var SPACE = { none: "0", xs: "4px", sm: "8px", md: "12px", lg: "16px", xl: "20px", "2xl": "24px", "3xl": "32px" };
|
||||
var RADIUS = { sm: "8px", md: "10px", lg: "12px", xl: "14px", "2xl": "16px", pill: "999px" };
|
||||
|
||||
// ── Rediseño de checada: paleta crema + fuentes de marca (flavor 'checada') ──
|
||||
// No afecta a panel/becario: sus componentes siguen usando COLORS/FONT.
|
||||
// ── Rediseño móvil: paleta crema + fuentes de marca (flavors 'checada' y 'becario') ──
|
||||
// No afecta a panel: sus componentes siguen usando COLORS/FONT.
|
||||
var CREAM = {
|
||||
bg: "#F3EBDD",
|
||||
bgGradient: "radial-gradient(120% 80% at 50% -10%, #FBF5EA 0%, #F3EBDD 55%, #EFE5D3 100%)",
|
||||
@@ -39,6 +39,10 @@ window.Theme = (function () {
|
||||
errBg: "#FBEBE8", errBorder: "#F3D3CC", errText: "#B4362A",
|
||||
warnBg: "#FBF0DC", warnBorder: "#EFD9A8", warnText: "#8A5A12",
|
||||
inputBorder: "#ECE3D4", inputBg: "#FBF8F2", track: "#EDE4D5", dashed: "#C7DBEC",
|
||||
// Portal del becario:
|
||||
neutralTint: "#EEE7D9", softTint: "#F1EADC", // píldora neutra / círculos y toggle
|
||||
okBorder: "#C4E3D2", okText: "#207A52", // nota de éxito verde
|
||||
metaBorder: "#CDE7D9", gold: "#F2B705", goldDark: "#E0A800", // "meta cumplida" + estrella
|
||||
};
|
||||
var FONT_TITLE = "'Bricolage Grotesque', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
|
||||
var FONT_BODY = "'Figtree', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif";
|
||||
@@ -121,6 +125,13 @@ window.Theme = (function () {
|
||||
lock: function (o) { o = o || {}; return ic([["rect",{x:4.5,y:10.5,width:15,height:10.5,rx:3}],["path",{d:"M8 10.5V7a4 4 0 0 1 8 0v3.5"}],["circle",{cx:12,cy:15.6,r:1.4,fill:o.color||"currentColor",stroke:"none"}]], o); },
|
||||
alertCircle: function (o) { return ic([["circle",{cx:12,cy:12,r:9.2}],["path",{d:"M12 7.6v5"}],["path",{d:"M12 16.2h.01"}]], o); },
|
||||
alertTriangle: function (o) { return ic([["path",{d:"M12 3 2.6 20h18.8L12 3z"}],["path",{d:"M12 9.6v4"}],["path",{d:"M12 17h.01"}]], o); },
|
||||
calendar: function (o) { return ic([["rect",{x:3.5,y:5,width:17,height:16,rx:3}],["path",{d:"M3.5 9.5h17"}],["path",{d:"M8 3v4"}],["path",{d:"M16 3v4"}]], o); },
|
||||
star: function (o) {
|
||||
o = o || {};
|
||||
return h("svg", { width: o.size || 20, height: o.size || 20, viewBox: "0 0 24 24",
|
||||
fill: o.color || CREAM.gold, stroke: o.stroke || CREAM.goldDark, strokeWidth: 1, strokeLinejoin: "round", style: o.style },
|
||||
h("path", { d: "M12 2.4l2.9 5.9 6.5.95-4.7 4.57 1.1 6.48L12 17.8l-5.8 3.06 1.1-6.48L2.6 9.25l6.5-.95z" }));
|
||||
},
|
||||
spinner: function (o) {
|
||||
o = o || {};
|
||||
return h("svg", { width: o.size || 18, height: o.size || 18, viewBox: "0 0 24 24", fill: "none",
|
||||
@@ -141,10 +152,11 @@ window.Theme = (function () {
|
||||
var icons = makeIcons(React);
|
||||
// tone (string) -> stroke del glifo, tinte del círculo, color del título.
|
||||
var STATE = {
|
||||
green: { stroke: C.green, tint: C.greenTint, title: C.green },
|
||||
blue: { stroke: C.primary, tint: C.blueTint, title: C.ink },
|
||||
amber: { stroke: C.amber, tint: C.amberTint, title: C.amber },
|
||||
danger: { stroke: C.danger, tint: C.dangerTint, title: C.danger },
|
||||
green: { stroke: C.green, tint: C.greenTint, title: C.green },
|
||||
blue: { stroke: C.primary, tint: C.blueTint, title: C.ink },
|
||||
amber: { stroke: C.amber, tint: C.amberTint, title: C.amber },
|
||||
danger: { stroke: C.danger, tint: C.dangerTint, title: C.danger },
|
||||
neutral: { stroke: C.inkSoft, tint: C.softTint, title: C.ink },
|
||||
};
|
||||
|
||||
function Logo(props) {
|
||||
@@ -168,20 +180,31 @@ window.Theme = (function () {
|
||||
}
|
||||
|
||||
function Btn(props) {
|
||||
var ghost = props.variant === "ghost"; // secundario: contorno azul, sin relleno
|
||||
var success = props.variant === "success";
|
||||
var bg = success ? C.green : C.primary;
|
||||
var shadow = success ? "0 12px 22px -10px rgba(47,138,99,.75)" : "0 12px 22px -10px rgba(46,119,184,.75)";
|
||||
var disabled = props.disabled;
|
||||
var style = {
|
||||
width: "100%", boxSizing: "border-box", padding: "15px", border: "none", borderRadius: "16px",
|
||||
background: disabled ? "#C6CFD8" : bg, color: disabled ? "#F4F8FC" : "#fff",
|
||||
width: "100%", boxSizing: "border-box", padding: "15px", borderRadius: "16px",
|
||||
fontFamily: fonts.body, fontSize: "15px", fontWeight: 700,
|
||||
cursor: disabled ? "not-allowed" : (props.loading ? "progress" : "pointer"),
|
||||
boxShadow: disabled ? "none" : shadow,
|
||||
display: "flex", alignItems: "center", justifyContent: "center", gap: "10px",
|
||||
};
|
||||
if (ghost) {
|
||||
style.background = "transparent";
|
||||
style.border = "1.5px solid " + (disabled ? "#C6CFD8" : C.primary);
|
||||
style.color = disabled ? "#B7C4D2" : C.primary;
|
||||
style.boxShadow = "none";
|
||||
} else {
|
||||
var bg = success ? C.green : C.primary;
|
||||
var shadow = success ? "0 12px 22px -10px rgba(47,138,99,.75)" : "0 12px 22px -10px rgba(46,119,184,.75)";
|
||||
style.border = "none";
|
||||
style.background = disabled ? "#C6CFD8" : bg;
|
||||
style.color = disabled ? "#F4F8FC" : "#fff";
|
||||
style.boxShadow = disabled ? "none" : shadow;
|
||||
}
|
||||
var kids = [];
|
||||
if (props.loading) kids.push(h("span", { key: "s", style: { display: "inline-flex" } }, icons.spinner({ size: 18 })));
|
||||
if (props.loading) kids.push(h("span", { key: "s", style: { display: "inline-flex" } },
|
||||
icons.spinner({ size: 18, color: ghost ? C.primary : "#fff", track: ghost ? C.line : undefined })));
|
||||
kids.push(h("span", { key: "t" }, props.children));
|
||||
return h("button", { type: props.type || "button", onClick: props.onClick, disabled: disabled, style: style }, kids);
|
||||
}
|
||||
@@ -197,9 +220,9 @@ window.Theme = (function () {
|
||||
}
|
||||
|
||||
function Aviso(props) {
|
||||
var warn = props.variant === "warn";
|
||||
var box = warn
|
||||
? { bg: C.warnBg, bd: C.warnBorder, text: C.warnText, ink: C.amber }
|
||||
var v = props.variant;
|
||||
var box = v === "warn" ? { bg: C.warnBg, bd: C.warnBorder, text: C.warnText, ink: C.amber }
|
||||
: v === "success" ? { bg: C.greenTint, bd: C.okBorder, text: C.okText, ink: C.green }
|
||||
: { bg: C.errBg, bd: C.errBorder, text: C.errText, ink: C.danger };
|
||||
var glyph = icons[props.icon] ? icons[props.icon]({ color: box.ink, size: 18, style: { flexShrink: 0 } }) : null;
|
||||
return h("div", { style: { display: "flex", gap: "10px", alignItems: "flex-start",
|
||||
@@ -228,14 +251,53 @@ window.Theme = (function () {
|
||||
return Card({ style: cardStyle, children: kids });
|
||||
}
|
||||
|
||||
// Píldora de estado. tone = string de estado real (activo/pendiente/cerrada/
|
||||
// abierta/revision/baja/autorizada/rechazada); mapea al color, no al revés.
|
||||
var BADGE = {
|
||||
activo: [C.greenTint, C.green], cerrada: [C.greenTint, C.green], autorizada: [C.greenTint, C.green],
|
||||
pendiente: [C.amberTint, C.amber], revision: [C.amberTint, C.amber],
|
||||
abierta: [C.neutralTint, C.inkSoft],
|
||||
baja: [C.dangerTint, C.danger], rechazada: [C.dangerTint, C.danger],
|
||||
};
|
||||
function StatusBadge(props) {
|
||||
var t = BADGE[props.tone] || [C.neutralTint, C.inkSoft];
|
||||
return h("span", { style: { display: "inline-block", padding: "3px 10px", borderRadius: "99px",
|
||||
fontFamily: fonts.body, fontSize: "11px", fontWeight: 600, background: t[0], color: t[1], whiteSpace: "nowrap" } }, props.children);
|
||||
}
|
||||
|
||||
// Tarjeta de horas con barra de avance. Al 100% muestra "¡Meta cumplida!".
|
||||
// Pinta valores del backend (total/meta/porcentaje/sub); no calcula nada.
|
||||
function HorasCard(props) {
|
||||
var pct = Math.max(0, Math.min(100, props.porcentaje || 0));
|
||||
var done = (props.porcentaje || 0) >= 100;
|
||||
var kids = [];
|
||||
if (done) {
|
||||
kids.push(h("div", { key: "stripe", style: { position: "absolute", top: 0, left: 0, right: 0, height: "4px",
|
||||
background: "linear-gradient(90deg," + C.green + "," + C.gold + ")" } }));
|
||||
kids.push(h("div", { key: "hdr", style: { display: "flex", alignItems: "center", gap: "8px", marginBottom: "8px" } },
|
||||
[ h("span", { key: "s", style: { display: "inline-flex" } }, icons.star({ size: 20 })),
|
||||
h("span", { key: "t", style: { fontFamily: fonts.title, fontWeight: 700, fontSize: "15px", color: C.green } }, "¡Meta cumplida!") ]));
|
||||
} else {
|
||||
kids.push(h("div", { key: "lbl", style: { fontFamily: fonts.body, fontWeight: 500, fontSize: "13px", color: C.inkSoft, marginBottom: "4px" } }, "Horas acumuladas"));
|
||||
}
|
||||
kids.push(h("div", { key: "num", style: { fontFamily: fonts.title, fontWeight: 700, fontSize: "30px", color: C.brand, letterSpacing: "-.01em", lineHeight: 1.1 } },
|
||||
[ props.total, " ", h("span", { key: "m", style: { fontFamily: fonts.body, fontWeight: 500, fontSize: "15px", color: C.inkSoft } }, "de " + props.meta) ]));
|
||||
kids.push(h("div", { key: "trk", style: { height: "9px", background: C.track, borderRadius: "99px", overflow: "hidden", margin: "13px 0 8px" } },
|
||||
h("div", { style: { height: "100%", width: pct + "%", background: done ? C.green : C.primary, borderRadius: "99px" } })));
|
||||
kids.push(h("div", { key: "sub", style: { fontFamily: fonts.body, fontWeight: 400, fontSize: "12px", color: done ? C.green : C.inkSoft } }, props.sub));
|
||||
return h("div", { style: { background: C.surface, border: "1px solid " + (done ? C.metaBorder : C.cardBorder),
|
||||
borderRadius: "20px", padding: "20px", boxShadow: "0 16px 34px -28px rgba(33,28,22,.3)", position: "relative", overflow: "hidden" } }, kids);
|
||||
}
|
||||
|
||||
return { Logo: Logo, IconBadge: IconBadge, Card: Card, Btn: Btn, Input: Input,
|
||||
Aviso: Aviso, Estado: Estado, palette: C, fonts: fonts, icons: icons };
|
||||
Aviso: Aviso, Estado: Estado, StatusBadge: StatusBadge, HorasCard: HorasCard,
|
||||
palette: C, fonts: fonts, icons: icons };
|
||||
}
|
||||
|
||||
function makeUI(flavor) {
|
||||
var React = window.React;
|
||||
var h = React.createElement;
|
||||
if (flavor === "checada") return makeCream(React); // rediseño: set cream propio
|
||||
if (flavor === "checada" || flavor === "becario") return makeCream(React); // rediseño móvil: set cream
|
||||
var F = FLAVORS[flavor];
|
||||
if (!F) throw new Error("Theme.makeUI: flavor desconocido '" + flavor + "'");
|
||||
|
||||
|
||||
Reference in new issue
Block a user