Files
Jorem JuárezandClaude Opus 4.8 e64a906413 ui: trazo de marca de dos lomas bajo "Powered by Collina Systems"
Recrea el mark de Collina (dos trazos: loma izquierda baja + loma derecha
alta) como SVG vectorial, reemplazando el flourish anterior. En las cuatro
páginas, tamaño proporcional al pie.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-08 21:45:39 -06:00

180 lines
9.4 KiB
HTML
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1.0"/>
<title>Taboada — Kiosco</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="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.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>
<div id="root"></div>
<script type="text/babel" data-presets="react">
const { useState, useEffect, useRef, useCallback } = React;
// Pantalla de kiosco (vector de presencia por QR). La abre la asistente en su
// teléfono con la cuenta de supervisora (misma cookie/guardia que el panel).
// Muestra un QR rotativo; el becario lo escanea con SU teléfono y aterriza en
// /checada.html?t=<token>, donde su propia sesión pone la identidad.
const { apiFetch } = Theme;
const UI = Theme.makeUI("checada"); // piel cream móvil
const { Logo, Card, Btn, Input, Aviso, Estado, palette, fonts, icons } = UI;
const Shell = ({ children }) => (
<div style={{ minHeight: "100vh", background: palette.bgGradient, display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", padding: "28px 20px", fontFamily: fonts.body }}>
<div style={{ width: "100%", maxWidth: "420px" }}>
<div style={{ display: "flex", justifyContent: "center", marginBottom: "22px" }}><Logo /></div>
{children}
<div style={{ textAlign: "center", padding: "18px 0 0", fontFamily: fonts.body, fontSize: "11px", color: palette.inkSoft, letterSpacing: ".02em" }}>
<div>Powered by <span style={{ fontWeight: 600, color: palette.brand }}>Collina Systems</span></div>
<svg width="66" height="21" viewBox="0 0 200 64" fill="none" aria-hidden="true" style={{ display: "block", margin: "6px auto 0" }}>
<path d="M6 45 C 34 45 46 31 64 31 C 82 31 92 41 122 44" stroke={palette.ink} strokeWidth="3.2" strokeLinecap="round" strokeLinejoin="round" opacity="0.82"/>
<path d="M84 47 C 104 47 118 22 140 21 C 162 20 176 40 196 42" stroke={palette.ink} strokeWidth="3.2" strokeLinecap="round" strokeLinejoin="round" opacity="0.82"/>
</svg>
</div>
</div>
</div>
);
const Cargando = ({ texto = "Cargando…" }) => (
<Card style={{ textAlign: "center" }}>
<div style={{ display: "flex", flexDirection: "column", alignItems: "center", gap: "12px" }}>
<span style={{ display: "inline-flex" }}>{icons.spinner({ size: 24, color: palette.primary, track: palette.line })}</span>
<span style={{ fontFamily: fonts.body, fontSize: "14px", color: palette.inkSoft }}>{texto}</span>
</div>
</Card>
);
// ═══════════════ Login de la asistente (cuenta de supervisora) ═══════════════
function Login({ onEntra }) {
const [f, setF] = useState({ usuario: "", password: "" });
const [error, setError] = useState(null);
const [busy, setBusy] = useState(false);
const submit = async (e) => {
e.preventDefault(); setBusy(true); setError(null);
try {
await apiFetch("/auth/login", { method: "POST", body: JSON.stringify(f) });
onEntra(await apiFetch("/auth/session"));
} catch (err) {
setError(err.status === 429 ? { text: "Demasiados intentos, espera un minuto.", ic: "clock" }
: { text: "Usuario o contraseña incorrectos.", ic: "alertCircle" });
} finally { setBusy(false); }
};
return (
<Card>
<h2 style={{ margin: "0 0 4px", fontFamily: fonts.title, fontWeight: 600, letterSpacing: "-.01em", color: palette.ink, fontSize: "22px", textAlign: "center" }}>Abrir kiosco</h2>
<p style={{ margin: "0 0 18px", fontFamily: fonts.body, color: palette.inkSoft, fontSize: "13px", textAlign: "center" }}>Inicia sesión para mostrar el código de checada.</p>
{error && <Aviso variant="error" icon={error.ic}>{error.text}</Aviso>}
<form onSubmit={submit}>
<div style={{ marginBottom: "12px" }}>
<Input placeholder="Usuario" value={f.usuario} onChange={(e) => setF({ ...f, usuario: e.target.value })} autoComplete="username" required />
</div>
<div style={{ marginBottom: "16px" }}>
<Input type="password" placeholder="Contraseña" value={f.password} onChange={(e) => setF({ ...f, password: e.target.value })} autoComplete="current-password" required />
</div>
<Btn type="submit" loading={busy} disabled={busy || !f.usuario || !f.password}>{busy ? "Entrando…" : "Entrar"}</Btn>
</form>
</Card>
);
}
// ═══════════════ Kiosco: QR rotativo ═══════════════
function Kiosco({ onSalir }) {
const [estado, setEstado] = useState(undefined); // undefined=cargando · {cerrado,token,rotacion_seg,...}
const [error, setError] = useState(null);
const qrHost = useRef(null); // div donde qrcodejs pinta
const qrObj = useRef(null); // instancia QRCode
const timer = useRef(null);
// Pide un token nuevo al servidor. 401 → sesión caída, vuelve al login.
const emitir = useCallback(async () => {
try {
const r = await apiFetch("/kiosco/qr", { method: "POST" });
setError(null); setEstado(r);
} catch (err) {
if (err.status === 401) { onSalir(); return; }
setError(err.status === 429 ? "Demasiadas solicitudes; espera un momento." : "No se pudo generar el código. Reintentando…");
}
}, [onSalir]);
useEffect(() => { emitir(); }, [emitir]);
// Reprograma la siguiente emisión según la rotación que devuelve el servidor.
// El token viejo sigue válido hasta su expiración (validez = rotacion×2), así
// que quien escanee justo en el cambio no se queda con un QR muerto.
useEffect(() => {
if (!estado) return;
const secs = estado.rotacion_seg || 45;
timer.current = setTimeout(emitir, secs * 1000);
return () => clearTimeout(timer.current);
}, [estado, emitir]);
// Repinta el QR cuando cambia el token (URL absoluta a /checada.html?t=…).
useEffect(() => {
if (!estado || estado.cerrado || !estado.token || !qrHost.current) return;
const url = `${window.location.origin}/checada.html?t=${estado.token}`;
if (!qrObj.current) {
qrObj.current = new QRCode(qrHost.current, { text: url, width: 264, height: 264, correctLevel: QRCode.CorrectLevel.M });
} else {
qrObj.current.clear();
qrObj.current.makeCode(url);
}
}, [estado]);
if (estado === undefined) return <Shell><Cargando texto="Generando código…" /></Shell>;
if (estado.cerrado) return (
<Shell>
<Estado icon="clock" tone="amber" title="Checado cerrado"
sub={`Fuera del horario de operación (${estado.ventana?.inicio}–${estado.ventana?.fin}). El código volverá al abrir la ventana.`}
action={<Btn variant="ghost" onClick={onSalir}>Cerrar kiosco</Btn>} />
</Shell>
);
return (
<Shell>
<Card style={{ textAlign: "center" }}>
<h2 style={{ margin: "0 0 4px", fontFamily: fonts.title, fontWeight: 600, letterSpacing: "-.01em", color: palette.ink, fontSize: "22px" }}>Escanea para registrar tu ingreso/salida</h2>
<p style={{ margin: "0 0 18px", fontFamily: fonts.body, color: palette.inkSoft, fontSize: "13px" }}>Acerca tu teléfono y escanea este código con la cámara.</p>
<div style={{ display: "flex", justifyContent: "center", marginBottom: "16px" }}>
<div ref={qrHost} style={{ display: "inline-block", padding: "16px", background: "#fff", borderRadius: "18px", border: `1px solid ${palette.cardBorder}`, lineHeight: 0 }} />
</div>
{error && <Aviso variant="error" icon="alertCircle">{error}</Aviso>}
<p style={{ margin: "0 0 16px", fontFamily: fonts.body, color: palette.inkSoft, fontSize: "12px" }}>
El código cambia cada {estado.rotacion_seg}s. Cada uno sirve una sola vez.
</p>
<Btn variant="ghost" onClick={onSalir}>Cerrar kiosco</Btn>
<p style={{ margin: "14px 0 0", fontFamily: fonts.body, color: palette.inkSoft, fontSize: "12px", lineHeight: 1.5 }}>
¿Problemas para escanear? Intenta actualizar la página.
</p>
</Card>
</Shell>
);
}
function App() {
const [session, setSession] = useState(undefined);
useEffect(() => { apiFetch("/auth/session").then(setSession).catch(() => setSession(null)); }, []);
const salir = async () => { try { await apiFetch("/auth/logout", { method: "POST" }); } catch {} setSession(null); };
if (session === undefined) return <Shell><Cargando texto="Verificando sesión…" /></Shell>;
if (!session) return <Shell><Login onEntra={setSession} /></Shell>;
return <Kiosco onSalir={salir} />;
}
ReactDOM.createRoot(document.getElementById("root")).render(<App />);
</script>
</body>
</html>