feat: soporte multi-carril con pestañas de entrada y salida y selector multi-puesto

This commit is contained in:
Carlos Tello
2026-10-14 20:53:16 -03:00
parent f95692ccb4
commit 0ab81a8c9c
2 changed files with 992 additions and 95 deletions
+186
View File
@@ -185,6 +185,71 @@ button:disabled, .btn:disabled, .touch-button:disabled {
border-color: var(--border);
}
/* ==============================================================================
PESTAÑAS DE CARRILES / PUESTOS DE CONTROL (PARIDAD QTabWidget DESKTOP)
============================================================================== */
.lane-tabs-nav {
display: flex;
align-items: center;
justify-content: space-between;
background-color: var(--bg-surface);
border-bottom: 1px solid var(--border);
padding: 0 1rem;
overflow-x: auto;
scrollbar-width: none;
min-height: 48px;
}
.lane-tabs-nav::-webkit-scrollbar {
display: none;
}
.lane-tabs-list {
display: flex;
align-items: center;
gap: 0.35rem;
}
.lane-tab-button {
background: transparent;
border: none;
border-bottom: 3px solid transparent;
border-radius: 6px 6px 0 0;
padding: 0.6rem 0.95rem;
font-size: 0.88rem;
font-weight: 700;
color: var(--text-secondary);
cursor: pointer;
display: inline-flex;
align-items: center;
gap: 0.5rem;
white-space: nowrap;
transition: all 0.15s ease;
min-height: 48px;
}
.lane-tab-button:hover {
background-color: var(--hover-bg);
color: var(--text-primary);
}
.lane-tab-button.active {
background-color: var(--hover-bg);
color: var(--text-primary);
}
.lane-tab-dot {
width: 9px;
height: 9px;
border-radius: 50%;
display: inline-block;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.4);
}
.lane-header-banner {
padding: 0.85rem 1.25rem;
border-bottom: 1px solid var(--border);
display: flex;
align-items: center;
justify-content: space-between;
flex-wrap: wrap;
gap: 0.75rem;
}
/* ==============================================================================
PESTAÑAS ESTILO ONEVER
============================================================================== */
@@ -352,3 +417,124 @@ button:disabled, .btn:disabled, .touch-button:disabled {
}
}
/* ==============================================================================
ESTILOS DE PESTAÑAS MULTI-CARRIL Y MULTI-PUESTO (PARIDAD ESCRITORIO PCT_VIEW_ADMIN)
============================================================================== */
.lane-tabs-nav {
display: flex;
align-items: center;
justify-content: space-between;
background-color: var(--bg-surface);
border-bottom: 1px solid var(--border-subtle);
padding: 0 1rem;
overflow-x: auto;
-webkit-overflow-scrolling: touch;
gap: 0.75rem;
min-height: 50px;
}
.lane-tabs-list {
display: flex;
align-items: center;
gap: 0.35rem;
flex: 1;
min-width: 0;
overflow-x: auto;
}
.lane-tab-button {
padding: 0.7rem 1.15rem;
min-height: 48px;
border: none;
border-bottom: 3px solid transparent;
background: transparent;
color: var(--text-secondary);
font-size: 0.92rem;
font-weight: 600;
cursor: pointer;
display: flex;
align-items: center;
gap: 0.55rem;
transition: all 0.2s ease;
border-radius: 8px 8px 0 0;
white-space: nowrap;
user-select: none;
}
.lane-tab-button:hover {
background-color: var(--hover-bg);
color: var(--text-primary);
}
.lane-tab-button.active {
color: var(--text-primary);
background-color: var(--bg-card);
font-weight: 700;
}
.lane-tab-button.active.tab-entry {
border-bottom-color: #10B981;
}
.lane-tab-button.active.tab-exit {
border-bottom-color: #EF4444;
}
.lane-tab-button.active.tab-overview {
border-bottom-color: var(--brand-primary);
}
.lane-tab-dot {
width: 11px;
height: 11px;
border-radius: 50%;
display: inline-block;
flex-shrink: 0;
}
.lane-tab-dot.entry {
background-color: #10B981;
box-shadow: 0 0 7px rgba(16, 185, 129, 0.7);
}
.lane-tab-dot.exit {
background-color: #EF4444;
box-shadow: 0 0 7px rgba(239, 68, 68, 0.7);
}
.lane-tab-dot.overview {
background-color: var(--brand-primary);
box-shadow: 0 0 7px rgba(0, 102, 204, 0.5);
}
.lane-header-banner {
display: flex;
align-items: center;
justify-content: space-between;
padding: 0.75rem 1.25rem;
border-bottom: 1px solid var(--border-subtle);
background: var(--bg-surface);
flex-wrap: wrap;
gap: 0.75rem;
}
.wks-switcher-btn {
display: flex;
align-items: center;
gap: 0.45rem;
padding: 0.45rem 0.85rem;
border-radius: 8px;
border: 1px solid var(--border);
background-color: var(--bg-card);
color: var(--text-primary);
font-weight: 600;
font-size: 0.85rem;
cursor: pointer;
transition: all 0.2s ease;
white-space: nowrap;
}
.wks-switcher-btn:hover {
background-color: var(--hover-bg);
border-color: var(--accent);
}
+806 -95
View File
@@ -4,7 +4,7 @@
// ==============================================================================
import React, { useState, useEffect, useCallback, useMemo } from 'react';
import { useAuth } from '../context/AuthContext';
import { workstationApi } from '../api/workstationApi';
import { workstationApi, WorkstationListItem } from '../api/workstationApi';
import { accessApi } from '../api/accessApi';
import { hardwareApi } from '../api/hardwareApi';
import { useWebSocket } from '../hooks/useWebSocket';
@@ -23,9 +23,18 @@ import {
LotPermission,
} from '../types';
export interface LaneTab {
key: string;
moduleId: number;
direction: 'ENTRY' | 'EXIT' | 'ALL';
name: string;
address: number;
tipo_acceso_nombre?: string;
es_acceso_peatonal?: boolean;
}
export const ControlPostView: React.FC = () => {
const { user, workstation, logout } = useAuth();
const { user, workstation, setWorkstation, logout } = useAuth();
const { theme, toggleTheme } = useTheme();
// Configuración de Estación y Módulos
@@ -33,6 +42,14 @@ export const ControlPostView: React.FC = () => {
const [selectedEntryModuleId, setSelectedEntryModuleId] = useState<number>(0);
const [selectedExitModuleId, setSelectedExitModuleId] = useState<number>(0);
// Soporte Multi-Carril (Pestañas de Entrada y Salida) y Multi-Puesto
const [activeLaneTabKey, setActiveLaneTabKey] = useState<string>('');
const [availableWorkstations, setAvailableWorkstations] = useState<WorkstationListItem[]>([]);
const [isWksModalOpen, setIsWksModalOpen] = useState<boolean>(false);
const [quickExitInput, setQuickExitInput] = useState<string>('');
const [quickExitMessage, setQuickExitMessage] = useState<{ text: string; type: 'success' | 'warn' | 'error' } | null>(null);
const [scannerMode, setScannerMode] = useState<'entry' | 'exit'>('entry');
// Tickets activos y movimientos registrados en BD
const [activeTickets, setActiveTickets] = useState<ActiveTicket[]>([]);
const [recentMovements, setRecentMovements] = useState<any[]>([]);
@@ -163,10 +180,95 @@ export const ControlPostView: React.FC = () => {
}
}, []);
// Carga de puestos de trabajo disponibles en la red
const loadAvailableWorkstations = useCallback(async () => {
try {
const list = await workstationApi.getAvailableWorkstations();
setAvailableWorkstations(list);
} catch (err) {
console.warn('Error cargando puestos disponibles:', err);
}
}, []);
useEffect(() => {
loadConfig();
loadActiveTickets();
}, [loadConfig, loadActiveTickets]);
loadAvailableWorkstations();
}, [loadConfig, loadActiveTickets, loadAvailableWorkstations]);
// Lista de carriles/pestañas del puesto actual (Paridad escritorio FormularioPuestoControlHost)
const laneTabs = useMemo<LaneTab[]>(() => {
const tabs: LaneTab[] = [];
if (config?.entry_modules) {
config.entry_modules.forEach((m) => {
tabs.push({
key: `entry-${m.id}`,
moduleId: m.id,
direction: 'ENTRY',
name: m.name,
address: m.address,
tipo_acceso_nombre: m.tipo_acceso_nombre,
es_acceso_peatonal: m.es_acceso_peatonal,
});
});
}
if (config?.exit_modules) {
config.exit_modules.forEach((m) => {
tabs.push({
key: `exit-${m.id}`,
moduleId: m.id,
direction: 'EXIT',
name: m.name,
address: m.address,
tipo_acceso_nombre: m.tipo_acceso_nombre,
es_acceso_peatonal: m.es_acceso_peatonal,
});
});
}
tabs.push({
key: 'overview',
moduleId: 0,
direction: 'ALL',
name: 'Predio y Movimientos',
address: 0,
});
return tabs;
}, [config]);
// Sincronizar carril activo al cargar o cambiar de puesto
useEffect(() => {
if (laneTabs.length > 0) {
const exists = laneTabs.some((t) => t.key === activeLaneTabKey);
if (!exists) {
const first = laneTabs[0];
setActiveLaneTabKey(first.key);
if (first.direction === 'ENTRY') {
setSelectedEntryModuleId(first.moduleId);
setForm((prev) => ({ ...prev, modulo_ingreso_id: first.moduleId }));
setScannerMode('entry');
} else if (first.direction === 'EXIT') {
setSelectedExitModuleId(first.moduleId);
setScannerMode('exit');
}
}
}
}, [laneTabs, activeLaneTabKey]);
const currentLaneTab = useMemo<LaneTab | undefined>(() => {
return laneTabs.find((t) => t.key === activeLaneTabKey) || laneTabs[0];
}, [laneTabs, activeLaneTabKey]);
const handleSelectLaneTab = (tab: LaneTab) => {
setActiveLaneTabKey(tab.key);
if (tab.direction === 'ENTRY') {
setSelectedEntryModuleId(tab.moduleId);
setForm((prev) => ({ ...prev, modulo_ingreso_id: tab.moduleId }));
setScannerMode('entry');
} else if (tab.direction === 'EXIT') {
setSelectedExitModuleId(tab.moduleId);
setScannerMode('exit');
}
};
// WebSockets para recepción de eventos en tiempo real
const handleWsEvent = useCallback(
@@ -311,18 +413,55 @@ export const ControlPostView: React.FC = () => {
setForm((prev) => ({ ...prev, [field]: `${yyyy}-${mm}-${dd}` }));
};
// Callback al escanear DNI con cámara
// Búsqueda y salida rápida por DNI o Patente (Paridad pct_view.py:3313 txt_doc / cmb_patente)
const handleQuickExitSearch = (query: string) => {
const q = query.trim().toUpperCase();
if (!q) return;
const cleanDni = q.replace(/[^0-9]/g, '');
const matched = activeTickets.find((t) => {
const matchDoc = cleanDni && cleanDni.length >= 4 && t.documento && t.documento.replace(/[^0-9]/g, '').includes(cleanDni);
const matchPat = t.patente && t.patente.toUpperCase().replace(/\s/g, '').includes(q.replace(/\s/g, ''));
const matchName = `${t.apellido} ${t.nombre}`.toUpperCase().includes(q);
return matchDoc || matchPat || matchName;
});
if (matched) {
setQuickExitMessage({
text: `Vehículo / Persona localizada: ${matched.patente || 'Peatón'} - ${matched.apellido}, ${matched.nombre}`,
type: 'success',
});
if (currentLaneTab && currentLaneTab.direction === 'EXIT') {
setSelectedExitModuleId(currentLaneTab.moduleId);
}
setTicketForExit(matched);
setExitModalOpen(true);
setQuickExitInput('');
} else {
setQuickExitMessage({
text: `No se encontró ningún ticket activo en el predio con "${query}".`,
type: 'warn',
});
setTimeout(() => setQuickExitMessage(null), 5000);
}
};
// Callback al escanear DNI con cámara (soporta Entrada y Salida)
const handleDniScanned = (data: DNIParsedResult) => {
setForm((prev) => ({
...prev,
documento: data.documento,
apellido: data.apellido,
nombre: data.nombre,
sexo: data.sexo || 'M',
}));
lookupPerson(data.documento);
setActionSuccess(`DNI escaneado exitosamente: ${data.apellido}, ${data.nombre} (${data.documento})`);
setTimeout(() => setActionSuccess(null), 4000);
if (scannerMode === 'exit') {
handleQuickExitSearch(data.documento);
} else {
setForm((prev) => ({
...prev,
documento: data.documento,
apellido: data.apellido,
nombre: data.nombre,
sexo: data.sexo || 'M',
}));
lookupPerson(data.documento);
setActionSuccess(`DNI escaneado exitosamente: ${data.apellido}, ${data.nombre} (${data.documento})`);
setTimeout(() => setActionSuccess(null), 4000);
}
};
// Envío del formulario de Ingreso con Validación Estricta
@@ -706,97 +845,542 @@ export const ControlPostView: React.FC = () => {
</div>
)}
{/* Barra de pestañas responsive para tablets en modo vertical y móviles */}
<div
className="portrait-tabs-bar"
style={{
display: 'none',
backgroundColor: 'var(--bg-surface)',
borderBottom: '1px solid var(--border)',
padding: '0.45rem 0.75rem',
gap: '0.5rem',
}}
>
<button
type="button"
onClick={() => setPortraitTab('entry')}
style={{
flex: 1,
padding: '0.65rem',
border: portraitTab === 'entry' ? '1px solid var(--brand-primary)' : '1px solid var(--border)',
borderRadius: '8px',
backgroundColor: portraitTab === 'entry' ? 'var(--brand-primary)' : 'var(--bg-app)',
color: portraitTab === 'entry' ? '#ffffff' : 'var(--text-primary)',
fontWeight: 700,
cursor: 'pointer',
fontSize: '0.9rem',
minHeight: '44px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '0.4rem',
}}
>
🚗 Registrar Ingreso
</button>
<button
type="button"
onClick={() => setPortraitTab('predio')}
style={{
flex: 1,
padding: '0.65rem',
border: portraitTab === 'predio' ? '1px solid var(--brand-primary)' : '1px solid var(--border)',
borderRadius: '8px',
backgroundColor: portraitTab === 'predio' ? 'var(--brand-primary)' : 'var(--bg-app)',
color: portraitTab === 'predio' ? '#ffffff' : 'var(--text-primary)',
fontWeight: 700,
cursor: 'pointer',
fontSize: '0.9rem',
minHeight: '44px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '0.4rem',
}}
>
📋 En Predio ({activeTickets.length})
</button>
</div>
{/* =========================================================================
Cuerpo Principal de Garita (Layout Cockpit con soporte Multiorientación)
Barra de Pestañas Multi-Carril y Multi-Puesto (Paridad Desktop FormularioPuestoControlHost)
========================================================================= */}
<div
className="cockpit-grid"
style={{
display: 'grid',
gridTemplateColumns: 'minmax(380px, 460px) 1fr',
flex: 1,
overflow: 'hidden',
}}
>
{/* =======================================================================
COLUMNA 1: FORMULARIO DE INGRESO RÁPIDO
======================================================================= */}
<section
className={`cockpit-entry-col ${portraitTab === 'entry' ? '' : 'portrait-tab-hidden'}`}
<nav className="lane-tabs-nav" aria-label="Carriles del Puesto de Control">
<div className="lane-tabs-list">
{laneTabs.map((tab) => {
const isActive = tab.key === activeLaneTabKey;
const tabClass =
tab.direction === 'ENTRY'
? 'tab-entry'
: tab.direction === 'EXIT'
? 'tab-exit'
: 'tab-overview';
const dotClass =
tab.direction === 'ENTRY'
? 'entry'
: tab.direction === 'EXIT'
? 'exit'
: 'overview';
return (
<button
key={tab.key}
type="button"
className={`lane-tab-button ${isActive ? 'active ' + tabClass : ''}`}
onClick={() => handleSelectLaneTab(tab)}
>
<span className={`lane-tab-dot ${dotClass}`} />
<span>
{tab.direction === 'ENTRY'
? `Entrada: ${tab.name}`
: tab.direction === 'EXIT'
? `Salida: ${tab.name}`
: `${tab.name}`}
</span>
{tab.direction === 'ALL' && (
<span
className="badge badge-info"
style={{ fontSize: '0.75rem', padding: '0.1rem 0.45rem', marginLeft: '0.25rem' }}
>
{activeTickets.length}
</span>
)}
</button>
);
})}
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
<button
type="button"
className="wks-switcher-btn"
onClick={() => {
loadAvailableWorkstations();
setIsWksModalOpen(true);
}}
title="Cambiar Puesto de Control / Garita"
>
<span>🏢</span>
<span>Puesto: <strong>{workstation}</strong></span>
<span style={{ fontSize: '0.7rem' }}>▼</span>
</button>
</div>
</nav>
{/* Banner de Estado del Carril Activo */}
{currentLaneTab && currentLaneTab.direction === 'ENTRY' && (
<div className="lane-header-banner">
<div style={{ display: 'flex', alignItems: 'center', gap: '0.65rem' }}>
<span className="lane-tab-dot entry" style={{ width: '13px', height: '13px' }} />
<div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', flexWrap: 'wrap' }}>
<strong style={{ fontSize: '0.95rem', color: 'var(--text-primary)' }}>
CARRIL DE ENTRADA: {currentLaneTab.name.toUpperCase()}
</strong>
<span style={{ fontSize: '0.75rem', color: 'var(--text-secondary)' }}>
(Módulo #{currentLaneTab.moduleId} • Addr {currentLaneTab.address})
</span>
</div>
<span style={{ fontSize: '0.75rem', color: 'var(--text-muted)' }}>
Habilitación: {currentLaneTab.tipo_acceso_nombre || (currentLaneTab.es_acceso_peatonal ? 'Molinete / Puerta Peatonal' : 'Barrera Vehicular')}
</span>
</div>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem' }}>
<button
type="button"
className="btn btn-secondary"
onClick={() => handleManualOpen(currentLaneTab.moduleId, currentLaneTab.name)}
style={{
minHeight: '36px',
padding: '0 0.85rem',
fontSize: '0.85rem',
fontWeight: 600,
display: 'flex',
alignItems: 'center',
gap: '0.35rem',
borderColor: '#10B981',
color: '#10B981',
}}
title="Enviar pulso de apertura manual a este módulo de entrada"
>
<span>⚡</span> Abrir Barrera Entrada
</button>
</div>
</div>
)}
{currentLaneTab && currentLaneTab.direction === 'EXIT' && (
<div className="lane-header-banner">
<div style={{ display: 'flex', alignItems: 'center', gap: '0.65rem' }}>
<span className="lane-tab-dot exit" style={{ width: '13px', height: '13px' }} />
<div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem', flexWrap: 'wrap' }}>
<strong style={{ fontSize: '0.95rem', color: 'var(--text-primary)' }}>
CARRIL DE SALIDA: {currentLaneTab.name.toUpperCase()}
</strong>
<span style={{ fontSize: '0.75rem', color: 'var(--text-secondary)' }}>
(Módulo #{currentLaneTab.moduleId} • Addr {currentLaneTab.address})
</span>
</div>
<span style={{ fontSize: '0.75rem', color: 'var(--text-muted)' }}>
Habilitación: {currentLaneTab.tipo_acceso_nombre || (currentLaneTab.es_acceso_peatonal ? 'Molinete / Puerta Peatonal' : 'Barrera Vehicular')}
</span>
</div>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem' }}>
<button
type="button"
className="btn btn-secondary"
onClick={() => handleManualOpen(currentLaneTab.moduleId, currentLaneTab.name)}
style={{
minHeight: '36px',
padding: '0 0.85rem',
fontSize: '0.85rem',
fontWeight: 600,
display: 'flex',
alignItems: 'center',
gap: '0.35rem',
borderColor: '#EF4444',
color: '#EF4444',
}}
title="Enviar pulso de apertura manual a este módulo de salida"
>
<span>⚡</span> Abrir Barrera Salida
</button>
</div>
</div>
)}
{/* Si el carril activo es SALIDA, renderizamos el Cockpit de Salida dedicado (Paridad pct_view.py _set_modo_salida) */}
{currentLaneTab && currentLaneTab.direction === 'EXIT' ? (
<div
style={{
backgroundColor: 'var(--bg-surface)',
borderRight: '1px solid var(--border-subtle)',
flex: 1,
display: 'flex',
flexDirection: 'column',
overflowY: 'auto',
padding: '1.25rem',
gap: '1rem',
backgroundColor: 'var(--bg-app)',
}}
>
{/* Botón Gigante de Escaneo con Cámara */}
<button
type="button"
className="btn btn-primary"
onClick={() => setScannerOpen(true)}
{/* Barra Superior de Salida: Cámara y Búsqueda Directa */}
<div
className="card"
style={{
width: '100%',
minHeight: '56px',
padding: '1.25rem',
backgroundColor: 'var(--bg-surface)',
borderRadius: '12px',
border: '2px solid #EF4444',
boxShadow: 'var(--shadow-sm)',
}}
>
<div style={{ display: 'flex', gap: '1rem', alignItems: 'center', flexWrap: 'wrap' }}>
<button
type="button"
className="btn"
onClick={() => {
setScannerMode('exit');
setScannerOpen(true);
}}
style={{
minHeight: '52px',
padding: '0 1.25rem',
fontSize: '1rem',
fontWeight: 700,
backgroundColor: '#EF4444',
color: '#fff',
display: 'flex',
alignItems: 'center',
gap: '0.6rem',
borderRadius: '8px',
boxShadow: '0 4px 12px rgba(239, 68, 68, 0.3)',
cursor: 'pointer',
}}
>
<span>📷</span> ESCANEAR DNI / CÉDULA PARA SALIDA
</button>
<form
onSubmit={(e) => {
e.preventDefault();
handleQuickExitSearch(quickExitInput);
}}
style={{ flex: 1, display: 'flex', gap: '0.6rem', minWidth: '280px' }}
>
<input
type="text"
className="input-touch"
placeholder="🔍 Ingrese DNI o Patente para salida rápida (Presione Enter)..."
value={quickExitInput}
onChange={(e) => setQuickExitInput(e.target.value)}
style={{
flex: 1,
minHeight: '52px',
fontSize: '1.05rem',
border: '2px solid #EF4444',
borderRadius: '8px',
padding: '0 1rem',
}}
/>
<button
type="submit"
className="btn"
style={{
minHeight: '52px',
padding: '0 1.25rem',
fontWeight: 700,
backgroundColor: 'var(--accent-primary)',
color: '#fff',
borderRadius: '8px',
whiteSpace: 'nowrap',
cursor: 'pointer',
}}
>
DAR SALIDA
</button>
</form>
</div>
{quickExitMessage && (
<div
style={{
marginTop: '0.75rem',
padding: '0.6rem 1rem',
borderRadius: '6px',
backgroundColor: quickExitMessage.type === 'success' ? 'var(--status-success-bg)' : 'var(--status-danger-bg)',
color: quickExitMessage.type === 'success' ? 'var(--status-success)' : 'var(--status-danger)',
border: `1px solid ${quickExitMessage.type === 'success' ? 'var(--status-success)' : 'var(--status-danger)'}`,
fontSize: '0.9rem',
fontWeight: 600,
}}
>
{quickExitMessage.text}
</div>
)}
</div>
{/* Grilla Principal de Salida */}
<div style={{ display: 'grid', gridTemplateColumns: 'minmax(0, 1fr) 340px', gap: '1rem', flex: 1 }}>
{/* Lista de Vehículos y Visitas en Predio */}
<div
className="card"
style={{
backgroundColor: 'var(--bg-surface)',
borderRadius: '12px',
padding: '1.25rem',
display: 'flex',
flexDirection: 'column',
gap: '0.85rem',
overflow: 'hidden',
}}
>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', gap: '0.75rem', flexWrap: 'wrap' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.5rem' }}>
<h3 style={{ margin: 0, fontSize: '1.1rem', fontWeight: 700 }}>
🚗 Visitas y Vehículos en Predio ({activeTickets.length})
</h3>
<span className="badge badge-info" style={{ fontSize: '0.8rem' }}>
{filteredTickets.length} mostrados
</span>
</div>
<input
type="text"
className="input-touch"
placeholder="Filtrar por DNI, patente o apellido..."
value={filterQuery}
onChange={(e) => setFilterQuery(e.target.value)}
style={{ maxWidth: '280px', minHeight: '40px', fontSize: '0.9rem' }}
/>
</div>
<div style={{ flex: 1, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: '0.65rem' }}>
{filteredTickets.length === 0 ? (
<div style={{ textAlign: 'center', padding: '3rem', color: 'var(--text-muted)' }}>
No hay vehículos ni visitas activas en el predio para dar salida.
</div>
) : (
filteredTickets.map((t) => (
<div
key={t.ticket_id}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '0.85rem 1.15rem',
backgroundColor: 'var(--bg-card)',
borderRadius: '8px',
border: '1px solid var(--border)',
flexWrap: 'wrap',
gap: '0.75rem',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '1rem', flexWrap: 'wrap' }}>
<div
style={{
backgroundColor: t.patente ? 'var(--status-info-bg)' : 'var(--status-warning-bg)',
color: t.patente ? 'var(--status-info)' : 'var(--status-warning)',
padding: '0.45rem 0.75rem',
borderRadius: '6px',
fontWeight: 700,
fontSize: '1.1rem',
minWidth: '95px',
textAlign: 'center',
border: `1px solid ${t.patente ? 'var(--status-info)' : 'var(--status-warning)'}`,
}}
>
{t.patente || 'PEATÓN'}
</div>
<div>
<div style={{ fontSize: '1rem', fontWeight: 600, color: 'var(--text-primary)' }}>
{t.apellido}, {t.nombre}{' '}
<span style={{ fontSize: '0.8rem', fontWeight: 400, color: 'var(--text-secondary)' }}>
(DNI: {t.documento})
</span>
</div>
<div style={{ fontSize: '0.8rem', color: 'var(--text-secondary)', marginTop: '0.2rem', display: 'flex', alignItems: 'center', flexWrap: 'wrap', gap: '0.4rem' }}>
<span>Destino: <strong>Lote {t.lote_codigo || 'S/D'}</strong> • Ingreso: {t.fecha_ingreso}</span>
{t.ocupantes > 1 && (
<span className="badge badge-neutral" style={{ fontSize: '0.75rem' }}>
👥 {t.ocupantes} personas
</span>
)}
{t.cacheo_salida && (
<span
style={{
backgroundColor: 'var(--status-danger-bg)',
color: 'var(--status-danger)',
border: '1px solid var(--status-danger)',
padding: '0.1rem 0.4rem',
borderRadius: '4px',
fontSize: '0.75rem',
fontWeight: 700,
}}
>
🔍 CACHEO OBLIGATORIO
</span>
)}
</div>
</div>
</div>
<button
type="button"
className="btn btn-danger"
onClick={() => {
setSelectedExitModuleId(currentLaneTab.moduleId);
handleOpenExitModal(t);
}}
style={{
fontWeight: 700,
minHeight: '46px',
padding: '0 1.25rem',
fontSize: '0.92rem',
whiteSpace: 'nowrap',
backgroundColor: '#EF4444',
}}
>
DAR SALIDA POR ESTA BARRERA
</button>
</div>
))
)}
</div>
</div>
{/* Columna Derecha: Movimientos recientes */}
<div
className="card"
style={{
backgroundColor: 'var(--bg-surface)',
borderRadius: '12px',
padding: '1.25rem',
display: 'flex',
flexDirection: 'column',
gap: '0.75rem',
overflow: 'hidden',
}}
>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
<h4 style={{ margin: 0, fontSize: '0.95rem', fontWeight: 700, color: 'var(--text-primary)' }}>
📋 Últimos Movimientos
</h4>
<button
type="button"
className="btn btn-secondary"
onClick={() => loadActiveTickets()}
style={{ minHeight: '32px', padding: '0 0.6rem', fontSize: '0.75rem' }}
>
🔄
</button>
</div>
<div style={{ flex: 1, overflowY: 'auto', display: 'flex', flexDirection: 'column', gap: '0.5rem' }}>
{recentMovements.slice(0, 12).map((m: any, idx: number) => (
<div
key={idx}
style={{
padding: '0.55rem 0.75rem',
borderRadius: '6px',
backgroundColor: 'var(--bg-card)',
border: '1px solid var(--border-subtle)',
fontSize: '0.8rem',
}}
>
<div style={{ display: 'flex', justifyContent: 'space-between', fontWeight: 600 }}>
<span>{m.patente || 'Peatón'}</span>
<span style={{ color: m.sentido === 'SALIDA' ? '#EF4444' : '#10B981' }}>{m.sentido}</span>
</div>
<div style={{ color: 'var(--text-secondary)', marginTop: '0.15rem' }}>
{m.apellido}, {m.nombre} (Lote {m.lote_codigo || '-'})
</div>
<div style={{ fontSize: '0.7rem', color: 'var(--text-muted)' }}>{m.fecha_hora}</div>
</div>
))}
</div>
</div>
</div>
</div>
) : (
/* Caso ENTRADA o PREDIO GENERAL: Layout Cockpit con soporte Multiorientación */
<>
{/* Barra de pestañas responsive para tablets en modo vertical y móviles */}
<div
className="portrait-tabs-bar"
style={{
display: 'none',
backgroundColor: 'var(--bg-surface)',
borderBottom: '1px solid var(--border)',
padding: '0.45rem 0.75rem',
gap: '0.5rem',
}}
>
<button
type="button"
onClick={() => setPortraitTab('entry')}
style={{
flex: 1,
padding: '0.65rem',
border: portraitTab === 'entry' ? '1px solid var(--brand-primary)' : '1px solid var(--border)',
borderRadius: '8px',
backgroundColor: portraitTab === 'entry' ? 'var(--brand-primary)' : 'var(--bg-app)',
color: portraitTab === 'entry' ? '#ffffff' : 'var(--text-primary)',
fontWeight: 700,
cursor: 'pointer',
fontSize: '0.9rem',
minHeight: '44px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '0.4rem',
}}
>
🚗 Registrar Ingreso
</button>
<button
type="button"
onClick={() => setPortraitTab('predio')}
style={{
flex: 1,
padding: '0.65rem',
border: portraitTab === 'predio' ? '1px solid var(--brand-primary)' : '1px solid var(--border)',
borderRadius: '8px',
backgroundColor: portraitTab === 'predio' ? 'var(--brand-primary)' : 'var(--bg-app)',
color: portraitTab === 'predio' ? '#ffffff' : 'var(--text-primary)',
fontWeight: 700,
cursor: 'pointer',
fontSize: '0.9rem',
minHeight: '44px',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
gap: '0.4rem',
}}
>
📋 En Predio ({activeTickets.length})
</button>
</div>
<div
className="cockpit-grid"
style={{
display: 'grid',
gridTemplateColumns: currentLaneTab?.direction === 'ALL' ? '1fr' : 'minmax(380px, 460px) 1fr',
flex: 1,
overflow: 'hidden',
}}
>
{/* =======================================================================
COLUMNA 1: FORMULARIO DE INGRESO RÁPIDO (Oculto en tab Predio General)
======================================================================= */}
{currentLaneTab?.direction !== 'ALL' && (
<section
className={`cockpit-entry-col ${portraitTab === 'entry' ? '' : 'portrait-tab-hidden'}`}
style={{
backgroundColor: 'var(--bg-surface)',
borderRight: '1px solid var(--border-subtle)',
display: 'flex',
flexDirection: 'column',
overflowY: 'auto',
padding: '1.25rem',
}}
>
{/* Botón Gigante de Escaneo con Cámara */}
<button
type="button"
className="btn btn-primary"
onClick={() => {
setScannerMode('entry');
setScannerOpen(true);
}}
style={{
width: '100%',
minHeight: '56px',
fontSize: '1.1rem',
fontWeight: 700,
display: 'flex',
@@ -1680,6 +2264,7 @@ export const ControlPostView: React.FC = () => {
</button>
</form>
</section>
)}
{/* =======================================================================
COLUMNA 2: TICKETS ACTIVOS Y EGRESOS DEL PREDIO
@@ -2060,6 +2645,8 @@ export const ControlPostView: React.FC = () => {
</footer>
</section>
</div>
</>
)}
{/* Modal de Escaneo con Cámara */}
<CameraScannerModal
@@ -2193,6 +2780,130 @@ export const ControlPostView: React.FC = () => {
onSelectLot={selectLot}
selectedLotId={form.lote_id}
/>
{/* Modal de Selección de Puesto de Trabajo (Multi-Puesto) */}
{isWksModalOpen && (
<div
className="modal-overlay"
onClick={() => setIsWksModalOpen(false)}
style={{
position: 'fixed',
top: 0,
left: 0,
right: 0,
bottom: 0,
backgroundColor: 'rgba(0, 0, 0, 0.7)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1000,
padding: '1rem',
}}
>
<div
className="card modal-responsive-card"
style={{
maxWidth: '520px',
width: '100%',
padding: '1.5rem',
backgroundColor: 'var(--bg-surface)',
borderRadius: '12px',
boxShadow: 'var(--shadow-lg)',
border: '1px solid var(--border)',
}}
onClick={(e) => e.stopPropagation()}
>
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '1rem' }}>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem' }}>
<span style={{ fontSize: '1.4rem' }}>🏢</span>
<h3 style={{ margin: 0, fontSize: '1.2rem', fontWeight: 700, color: 'var(--text-primary)' }}>
Seleccionar Puesto de Control
</h3>
</div>
<button
type="button"
onClick={() => setIsWksModalOpen(false)}
style={{ background: 'none', border: 'none', fontSize: '1.25rem', cursor: 'pointer', color: 'var(--text-secondary)' }}
>
✕
</button>
</div>
<p style={{ fontSize: '0.9rem', color: 'var(--text-secondary)', marginBottom: '1.25rem', lineHeight: 1.4 }}>
Seleccione la estación o garita que desea operar. Se cargarán sus carriles virtuales, barreras de entrada/salida y lectores asociados.
</p>
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.65rem', maxHeight: '350px', overflowY: 'auto' }}>
{availableWorkstations.length === 0 ? (
<div style={{ textAlign: 'center', padding: '1.5rem', color: 'var(--text-muted)' }}>
Cargando estaciones de trabajo registradas...
</div>
) : (
availableWorkstations.map((wks) => {
const isCurrent = wks.name.toUpperCase() === workstation.toUpperCase();
return (
<button
key={wks.id || wks.name}
type="button"
onClick={() => {
setWorkstation(wks.name);
setIsWksModalOpen(false);
setActionSuccess(`✓ Conectado a la estación: ${wks.name}`);
setTimeout(() => setActionSuccess(null), 4000);
}}
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
padding: '0.9rem 1.15rem',
borderRadius: '8px',
border: isCurrent ? '2px solid var(--brand-primary)' : '1px solid var(--border)',
backgroundColor: isCurrent ? 'var(--hover-bg)' : 'var(--bg-card)',
color: 'var(--text-primary)',
fontWeight: isCurrent ? 700 : 500,
fontSize: '0.95rem',
cursor: 'pointer',
textAlign: 'left',
transition: 'all 0.15s ease',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem' }}>
<span style={{ fontSize: '1.3rem' }}>🖥️</span>
<div>
<div style={{ fontWeight: 700 }}>{wks.name}</div>
<div style={{ fontSize: '0.75rem', color: 'var(--text-secondary)' }}>
ID Estación: #{wks.id}
</div>
</div>
</div>
{isCurrent ? (
<span className="badge badge-success" style={{ fontSize: '0.75rem' }}>
● ACTIVO
</span>
) : (
<span style={{ fontSize: '0.85rem', color: 'var(--text-muted)' }}>
Seleccionar →
</span>
)}
</button>
);
})
)}
</div>
<div style={{ marginTop: '1.5rem', display: 'flex', justifyContent: 'flex-end' }}>
<button
type="button"
className="btn btn-secondary"
onClick={() => setIsWksModalOpen(false)}
style={{ minHeight: '42px', padding: '0 1.25rem', fontWeight: 600 }}
>
Cerrar
</button>
</div>
</div>
</div>
)}
</div>
);
};