feat: complete Phases 2 to 5 inclusive - Access Core, Web Cockpit, Hardware enqueuing, Optical Scanner and QA (v0.5.0-beta)
This commit is contained in:
@@ -0,0 +1,200 @@
|
||||
// ==============================================================================
|
||||
// Vista de Inicio de Sesión de Operador / Guardia
|
||||
// Optimizado para uso táctil en tablets Samsung Galaxy Tab (Touch-First)
|
||||
// ==============================================================================
|
||||
import React, { useState } from 'react';
|
||||
import { useAuth } from '../context/AuthContext';
|
||||
|
||||
export const LoginView: React.FC = () => {
|
||||
const { login, workstation, setWorkstation } = useAuth();
|
||||
const [username, setUsername] = useState<string>('guardia');
|
||||
const [password, setPassword] = useState<string>('');
|
||||
const [selectedWks, setSelectedWks] = useState<string>(workstation || 'CFT-DESK');
|
||||
const [isLoading, setIsLoading] = useState<boolean>(false);
|
||||
const [errorMsg, setErrorMsg] = useState<string | null>(null);
|
||||
|
||||
const handleSubmit = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!username.trim() || !password) {
|
||||
setErrorMsg('Ingrese usuario y contraseña');
|
||||
return;
|
||||
}
|
||||
|
||||
setIsLoading(true);
|
||||
setErrorMsg(null);
|
||||
|
||||
try {
|
||||
setWorkstation(selectedWks);
|
||||
await login(username.trim(), password, selectedWks);
|
||||
} catch (err: any) {
|
||||
setErrorMsg(err.message || 'Error al iniciar sesión. Verifique sus credenciales.');
|
||||
} finally {
|
||||
setIsLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div
|
||||
style={{
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
minHeight: '100%',
|
||||
backgroundColor: 'var(--bg-app)',
|
||||
padding: '1.5rem',
|
||||
}}
|
||||
>
|
||||
<div
|
||||
className="card"
|
||||
style={{
|
||||
width: '100%',
|
||||
maxWidth: '460px',
|
||||
boxShadow: 'var(--shadow-lg)',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
borderRadius: 'var(--radius-lg)',
|
||||
padding: '2rem',
|
||||
}}
|
||||
>
|
||||
{/* Cabecera del Login */}
|
||||
<div style={{ textAlign: 'center', marginBottom: '2rem' }}>
|
||||
<div
|
||||
style={{
|
||||
width: '64px',
|
||||
height: '64px',
|
||||
borderRadius: '16px',
|
||||
backgroundColor: 'var(--accent-primary-alpha)',
|
||||
display: 'inline-flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
fontSize: '2rem',
|
||||
marginBottom: '1rem',
|
||||
}}
|
||||
>
|
||||
🛡️
|
||||
</div>
|
||||
<h1 style={{ fontSize: '1.6rem', fontWeight: 700, margin: '0 0 0.5rem 0', color: 'var(--text-primary)' }}>
|
||||
OnEverControl
|
||||
</h1>
|
||||
<p style={{ margin: 0, fontSize: '0.9rem', color: 'var(--text-muted)' }}>
|
||||
Puesto de Control Web • Modo Cliente Garita
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{/* Alerta de Error */}
|
||||
{errorMsg && (
|
||||
<div
|
||||
style={{
|
||||
padding: '0.75rem 1rem',
|
||||
backgroundColor: 'var(--status-danger-bg)',
|
||||
color: 'var(--status-danger)',
|
||||
borderRadius: 'var(--radius-sm)',
|
||||
marginBottom: '1.5rem',
|
||||
fontSize: '0.9rem',
|
||||
border: '1px solid var(--status-danger)',
|
||||
}}
|
||||
>
|
||||
⚠️ {errorMsg}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<form onSubmit={handleSubmit} style={{ display: 'flex', flexDirection: 'column', gap: '1.25rem' }}>
|
||||
{/* Selector de Workstation / Garita */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
fontSize: '0.85rem',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-secondary)',
|
||||
marginBottom: '0.5rem',
|
||||
}}
|
||||
>
|
||||
Puesto de Control / Workstation:
|
||||
</label>
|
||||
<select
|
||||
className="input-touch"
|
||||
value={selectedWks}
|
||||
onChange={(e) => setSelectedWks(e.target.value)}
|
||||
style={{ width: '100%' }}
|
||||
>
|
||||
<option value="CFT-DESK">CFT-DESK (Garita Principal)</option>
|
||||
<option value="GARITA_SUR">GARITA_SUR</option>
|
||||
<option value="GARITA_NORTE">GARITA_NORTE</option>
|
||||
<option value="ACCESO_PROVEEDORES">ACCESO_PROVEEDORES</option>
|
||||
</select>
|
||||
</div>
|
||||
|
||||
{/* Campo Usuario */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
fontSize: '0.85rem',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-secondary)',
|
||||
marginBottom: '0.5rem',
|
||||
}}
|
||||
>
|
||||
Usuario:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={username}
|
||||
onChange={(e) => setUsername(e.target.value)}
|
||||
placeholder="Ej: guardia, supervisor"
|
||||
autoCapitalize="none"
|
||||
autoCorrect="off"
|
||||
required
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Campo Contraseña */}
|
||||
<div>
|
||||
<label
|
||||
style={{
|
||||
display: 'block',
|
||||
fontSize: '0.85rem',
|
||||
fontWeight: 600,
|
||||
color: 'var(--text-secondary)',
|
||||
marginBottom: '0.5rem',
|
||||
}}
|
||||
>
|
||||
Contraseña:
|
||||
</label>
|
||||
<input
|
||||
type="password"
|
||||
className="input-touch"
|
||||
value={password}
|
||||
onChange={(e) => setPassword(e.target.value)}
|
||||
placeholder="••••••••"
|
||||
required
|
||||
style={{ width: '100%' }}
|
||||
/>
|
||||
</div>
|
||||
|
||||
{/* Botón de Ingreso Táctil */}
|
||||
<button
|
||||
type="submit"
|
||||
className="btn btn-primary"
|
||||
disabled={isLoading}
|
||||
style={{
|
||||
width: '100%',
|
||||
minHeight: '52px',
|
||||
fontSize: '1.05rem',
|
||||
fontWeight: 600,
|
||||
marginTop: '0.5rem',
|
||||
}}
|
||||
>
|
||||
{isLoading ? 'Iniciando Sesión...' : 'Iniciar Turno'}
|
||||
</button>
|
||||
</form>
|
||||
|
||||
<div style={{ marginTop: '2rem', textAlign: 'center', fontSize: '0.75rem', color: 'var(--text-muted)' }}>
|
||||
OnEverControl Web v0.5.0-beta • Samsung Galaxy Tab Ready
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user