feat(parity): implement Bloques 1, 2 y 3 complete feature parity v0.7.0-beta

This commit is contained in:
Carlos Tello
2026-10-29 20:52:58 -03:00
parent 918b87c645
commit ad92bb5fc1
28 changed files with 3704 additions and 118 deletions
+39
View File
@@ -10,6 +10,11 @@ import {
PersonSearchItem,
LotSearchItem,
DNIParsedResult,
Preauthorization,
VehicleSearchResult,
PersonAdvancedSearchResult,
MassExitRequest,
MassExitResult,
} from '../types';
export const accessApi = {
@@ -87,6 +92,40 @@ export const accessApi = {
method: 'GET',
});
},
getPreauthorizations: (query: string = '', soloVigentes: boolean = true) => {
return request<Preauthorization[]>(
`/access/preauthorizations?q=${encodeURIComponent(query)}&solo_vigentes=${soloVigentes}`,
{ method: 'GET' }
);
},
consumePreauthorization: (id: number) => {
return request<{ status: string; message: string }>(`/access/preauthorizations/${id}/consume`, {
method: 'POST',
});
},
searchPeopleAdvanced: (query: string, limit: number = 50) => {
return request<PersonAdvancedSearchResult[]>(
`/access/people/advanced-search?q=${encodeURIComponent(query)}&limite=${limit}`,
{ method: 'GET' }
);
},
searchVehicles: (query: string = '', esSalida: boolean = false, limit: number = 50) => {
return request<VehicleSearchResult[]>(
`/access/vehicles/search?q=${encodeURIComponent(query)}&es_salida=${esSalida}&limite=${limit}`,
{ method: 'GET' }
);
},
executeMassExit: (data: MassExitRequest) => {
return request<MassExitResult>('/access/mass-exit', {
method: 'POST',
body: JSON.stringify(data),
});
},
};
+7
View File
@@ -19,4 +19,11 @@ export const hardwareApi = {
body: JSON.stringify({ modulo_id: moduloId, motivo, ticket_id: ticketId }),
});
},
manualClose: (moduloId: number, motivo: string = 'CIERRE_FORZADO_GUARDIA', ticketId: number = 0) => {
return request<HardwareCommandResponse>(`/hardware/modules/${moduloId}/close`, {
method: 'POST',
body: JSON.stringify({ modulo_id: moduloId, motivo, ticket_id: ticketId }),
});
},
};
@@ -0,0 +1,446 @@
// ==============================================================================
// Modal de Salida Masiva / Toque de Queda
// Paridad 1:1 con DlgSalidaMasiva (pct_dialogs.py:1593 - OneverAccess / OemspotPySYS)
// ==============================================================================
import React, { useState, useEffect, useMemo, useCallback } from 'react';
import { ActiveTicket, MassExitRequest } from '../../types';
import { accessApi } from '../../api/accessApi';
interface MassExitModalProps {
isOpen: boolean;
onClose: () => void;
moduloSalidaId: number;
onSuccess: (count: number) => void;
}
export const MassExitModal: React.FC<MassExitModalProps> = ({
isOpen,
onClose,
moduloSalidaId,
onSuccess,
}) => {
const [tickets, setTickets] = useState<ActiveTicket[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [filterText, setFilterText] = useState<string>('');
const [selectedTicketIds, setSelectedTicketIds] = useState<Set<number>>(new Set());
const [motivo, setMotivo] = useState<string>('Toque de queda / Cierre de jornada');
const [observaciones, setObservaciones] = useState<string>('');
const [isSubmitting, setIsSubmitting] = useState<boolean>(false);
const [errorMsg, setErrorMsg] = useState<string>('');
// Cargar tickets activos al abrir
const loadTickets = useCallback(async () => {
setIsLoading(true);
setErrorMsg('');
try {
const data = await accessApi.getActiveTickets();
setTickets(data);
} catch (e: any) {
console.error('Error al cargar tickets para salida masiva:', e);
setErrorMsg('No se pudieron cargar los tickets activos del predio.');
} finally {
setIsLoading(false);
}
}, []);
useEffect(() => {
if (isOpen) {
setSelectedTicketIds(new Set());
setFilterText('');
setObservaciones('');
loadTickets();
}
}, [isOpen, loadTickets]);
// Filtrado reactivo multi-término
const filteredTickets = useMemo(() => {
const terms = filterText.trim().toLowerCase().split(/\s+/).filter(Boolean);
if (terms.length === 0) return tickets;
return tickets.filter((t) => {
const ape = (t.apellido || '').toLowerCase();
const nom = (t.nombre || '').toLowerCase();
const doc = (t.documento || '').toLowerCase();
const pat = (t.patente || '').toLowerCase();
const lot = (t.lote_nombre || t.lote_codigo || String(t.lote_id || '')).toLowerCase();
const ent = (t.entidad || '').toLowerCase();
const blob = `${ape} ${nom} ${doc} ${pat} ${lot} ${ent}`;
return terms.every((term) => blob.includes(term));
});
}, [tickets, filterText]);
const handleToggleSelectAll = (select: boolean) => {
if (select) {
const allIds = new Set(filteredTickets.map((t) => t.ticket_id));
setSelectedTicketIds(allIds);
} else {
setSelectedTicketIds(new Set());
}
};
const handleToggleRow = (ticketId: number) => {
setSelectedTicketIds((prev) => {
const next = new Set(prev);
if (next.has(ticketId)) {
next.delete(ticketId);
} else {
next.add(ticketId);
}
return next;
});
};
const handleConfirmExit = async () => {
if (selectedTicketIds.size === 0) return;
const confirmMsg = `¿Confirma el egreso de ${selectedTicketIds.size} persona(s) por motivo "${motivo}"?`;
if (!window.confirm(confirmMsg)) return;
setIsSubmitting(true);
setErrorMsg('');
try {
const payload: MassExitRequest = {
ticket_ids: Array.from(selectedTicketIds),
modulo_salida_id: moduloSalidaId,
motivo,
observaciones,
};
const result = await accessApi.executeMassExit(payload);
onSuccess(result.egresados_count);
onClose();
} catch (e: any) {
console.error('Error al procesar salida masiva:', e);
setErrorMsg(e?.message || 'Error en el servidor al procesar la salida masiva.');
} finally {
setIsSubmitting(false);
}
};
if (!isOpen) return null;
return (
<div
style={{
position: 'fixed',
inset: 0,
backgroundColor: 'rgba(0, 0, 0, 0.70)',
backdropFilter: 'blur(4px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1100,
padding: '1rem',
}}
onClick={(e) => {
if (e.target === e.currentTarget && !isSubmitting) onClose();
}}
>
<div
className="card"
style={{
width: '100%',
maxWidth: '1080px',
maxHeight: '92vh',
display: 'flex',
flexDirection: 'column',
boxShadow: 'var(--shadow-xl)',
border: '1.5px solid rgba(220, 38, 38, 0.4)',
borderRadius: 'var(--radius-md)',
backgroundColor: 'var(--bg-surface)',
overflow: 'hidden',
animation: 'fadeIn 0.15s ease-out',
}}
>
{/* Cabecera de Alerta */}
<div
style={{
padding: '1rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem' }}>
<span style={{ fontSize: '1.8rem' }}>🚨</span>
<div>
<h3 style={{ margin: 0, fontSize: '1.25rem', fontWeight: 900, color: '#dc2626', letterSpacing: '0.5px' }}>
SALIDA MASIVA / TOQUE DE QUEDA
</h3>
<p style={{ margin: 0, fontSize: '0.8rem', color: 'var(--text-secondary)' }}>
Gestione el retiro rápido o simultáneo de visitas y ocupantes registrados actualmente dentro del predio.
</p>
</div>
</div>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem' }}>
<span
style={{
backgroundColor: 'rgba(59, 130, 246, 0.15)',
color: 'var(--accent-primary)',
border: '1.5px solid rgba(59, 130, 246, 0.3)',
borderRadius: '20px',
fontSize: '0.85rem',
fontWeight: 700,
padding: '0.35rem 1rem',
}}
>
Total en predio: <b>{tickets.length}</b> | Seleccionados: <b>{selectedTicketIds.size}</b>
</span>
<button
type="button"
className="btn btn-secondary"
onClick={onClose}
disabled={isSubmitting}
style={{ minHeight: '36px', minWidth: '36px', padding: 0 }}
>
✕
</button>
</div>
</div>
{errorMsg && (
<div style={{ padding: '0.75rem 1.25rem', backgroundColor: 'rgba(239, 68, 68, 0.15)', color: '#ef4444', fontWeight: 600, fontSize: '0.85rem', borderBottom: '1px solid rgba(239, 68, 68, 0.3)' }}>
⚠️ {errorMsg}
</div>
)}
{/* Barra de Búsqueda y Selección */}
<div
style={{
padding: '0.75rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-surface)',
display: 'flex',
gap: '0.6rem',
alignItems: 'center',
}}
>
<div style={{ flex: 1, position: 'relative' }}>
<input
type="text"
className="input-field"
placeholder="🔍 Filtrar por Documento, Apellido, Nombre, Lote o Patente..."
value={filterText}
onChange={(e) => setFilterText(e.target.value)}
style={{ minHeight: '40px' }}
/>
</div>
<button
type="button"
className="btn btn-secondary"
onClick={() => handleToggleSelectAll(true)}
style={{ minHeight: '40px', fontWeight: 600, fontSize: '0.85rem', whiteSpace: 'nowrap' }}
>
☑ Seleccionar Todos
</button>
<button
type="button"
className="btn btn-secondary"
onClick={() => handleToggleSelectAll(false)}
style={{ minHeight: '40px', fontWeight: 600, fontSize: '0.85rem', whiteSpace: 'nowrap' }}
>
☐ Deseleccionar
</button>
<button
type="button"
className="btn btn-secondary"
onClick={loadTickets}
disabled={isLoading}
style={{ minHeight: '40px', fontSize: '0.85rem', whiteSpace: 'nowrap' }}
>
🔄 Actualizar
</button>
</div>
{/* Grilla de Personas en Predio */}
<div style={{ flex: 1, overflowY: 'auto', padding: '0.5rem 1.25rem' }}>
<div
style={{
maxHeight: '360px',
overflowY: 'auto',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-sm)',
backgroundColor: 'var(--bg-app)',
}}
>
{filteredTickets.length === 0 && !isLoading ? (
<div style={{ padding: '2rem', textAlign: 'center', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
No hay personas ingresadas actualmente que coincidan con el filtro.
</div>
) : (
<table style={{ width: '100%', borderCollapse: 'collapse', textAlign: 'left', fontSize: '0.85rem' }}>
<thead>
<tr style={{ backgroundColor: 'var(--bg-surface)', borderBottom: '1px solid var(--border-subtle)' }}>
<th style={{ padding: '0.55rem 0.6rem', width: '40px', textAlign: 'center' }}>✓</th>
<th style={{ padding: '0.55rem 0.6rem', width: '130px' }}>Ingreso</th>
<th style={{ padding: '0.55rem 0.6rem', width: '110px' }}>Documento</th>
<th style={{ padding: '0.55rem 0.6rem' }}>Apellido y Nombre</th>
<th style={{ padding: '0.55rem 0.6rem', width: '110px' }}>Lote / Destino</th>
<th style={{ padding: '0.55rem 0.6rem', width: '100px' }}>Patente</th>
<th style={{ padding: '0.55rem 0.6rem' }}>Rol / Entidad</th>
<th style={{ padding: '0.55rem 0.6rem', width: '80px' }}>Ticket</th>
</tr>
</thead>
<tbody>
{filteredTickets.map((t) => {
const isChecked = selectedTicketIds.has(t.ticket_id);
const nombreCompleto = `${t.apellido || ''} ${t.nombre || ''}`.trim() || 'Sin Nombre';
return (
<tr
key={t.ticket_id}
onClick={() => handleToggleRow(t.ticket_id)}
style={{
cursor: 'pointer',
backgroundColor: isChecked ? 'rgba(220, 38, 38, 0.16)' : 'transparent',
borderBottom: '1px solid var(--border-subtle)',
fontWeight: isChecked ? 700 : 400,
borderLeft: isChecked ? '4px solid #dc2626' : '4px solid transparent',
transition: 'background 0.1s ease',
}}
>
<td style={{ padding: '0.55rem 0.6rem', textAlign: 'center' }}>
<input
type="checkbox"
checked={isChecked}
onChange={() => handleToggleRow(t.ticket_id)}
style={{ cursor: 'pointer', width: '16px', height: '16px' }}
/>
</td>
<td style={{ padding: '0.55rem 0.6rem', fontSize: '0.78rem', color: 'var(--text-secondary)' }}>
{t.fecha_ingreso ? t.fecha_ingreso.slice(0, 16) : '-'}
</td>
<td style={{ padding: '0.55rem 0.6rem', color: 'var(--text-primary)' }}>
<strong>{t.documento || '-'}</strong>
</td>
<td style={{ padding: '0.55rem 0.6rem', color: 'var(--text-primary)' }}>
{nombreCompleto}
</td>
<td style={{ padding: '0.55rem 0.6rem' }}>
<span style={{ fontWeight: 600, color: 'var(--text-primary)' }}>
{t.lote_nombre ? `Lote ${t.lote_nombre}` : (t.lote_codigo ? `Lote ${t.lote_codigo}` : '-')}
</span>
</td>
<td style={{ padding: '0.55rem 0.6rem' }}>
{t.patente ? (
<span style={{ fontFamily: 'monospace', fontWeight: 700, color: 'var(--accent-primary)' }}>
{t.patente}
</span>
) : (
<span style={{ color: 'var(--text-muted)' }}>Peatonal</span>
)}
</td>
<td style={{ padding: '0.55rem 0.6rem', color: 'var(--text-secondary)' }}>
{t.entidad || (t.rol_id === 1 ? 'Conductor' : (t.patente ? 'Conductor' : 'Visitante'))}
</td>
<td style={{ padding: '0.55rem 0.6rem', color: 'var(--text-muted)', fontSize: '0.75rem' }}>
#{t.ticket_id}
</td>
</tr>
);
})}
</tbody>
</table>
)}
</div>
</div>
{/* Motivo y Observaciones */}
<div
style={{
padding: '0.85rem 1.25rem',
borderTop: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-app)',
display: 'grid',
gridTemplateColumns: '260px 1fr',
gap: '1rem',
alignItems: 'center',
}}
>
<div>
<label style={{ display: 'block', fontSize: '0.75rem', fontWeight: 700, color: 'var(--text-secondary)', marginBottom: '0.25rem', textTransform: 'uppercase' }}>
Motivo Operativo:
</label>
<select
className="input-field"
value={motivo}
onChange={(e) => setMotivo(e.target.value)}
style={{ minHeight: '40px', fontWeight: 600 }}
>
<option value="Toque de queda / Cierre de jornada">Toque de queda / Cierre de jornada</option>
<option value="Evacuación preventiva de emergencia">Evacuación preventiva de emergencia</option>
<option value="Fin de evento masivo / Visitas">Fin de evento masivo / Visitas</option>
<option value="Cierre operativo nocturno">Cierre operativo nocturno</option>
<option value="Retiro por orden de administración">Retiro por orden de administración</option>
</select>
</div>
<div>
<label style={{ display: 'block', fontSize: '0.75rem', fontWeight: 700, color: 'var(--text-secondary)', marginBottom: '0.25rem', textTransform: 'uppercase' }}>
Observaciones adicionales:
</label>
<input
type="text"
className="input-field"
placeholder="Detalle o nota para el acta de auditoría..."
value={observaciones}
onChange={(e) => setObservaciones(e.target.value)}
style={{ minHeight: '40px' }}
/>
</div>
</div>
{/* Footer */}
<div
style={{
padding: '1rem 1.25rem',
borderTop: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-surface)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<div style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}>
Carril de Egreso Asignado: <b>Módulo #{moduloSalidaId}</b>
</div>
<div style={{ display: 'flex', gap: '0.75rem' }}>
<button
type="button"
className="btn btn-secondary"
onClick={onClose}
disabled={isSubmitting}
style={{ minHeight: '44px', padding: '0 1.25rem' }}
>
Cancelar
</button>
<button
type="button"
className="btn btn-danger"
disabled={selectedTicketIds.size === 0 || isSubmitting}
onClick={handleConfirmExit}
style={{
minHeight: '44px',
padding: '0 1.75rem',
fontWeight: 900,
backgroundColor: '#dc2626',
color: '#ffffff',
border: 'none',
boxShadow: selectedTicketIds.size > 0 ? '0 0 12px rgba(220, 38, 38, 0.4)' : 'none',
}}
>
{isSubmitting
? 'Procesando...'
: `🚨 Confirmar Salida Masiva (${selectedTicketIds.size} seleccionados)`}
</button>
</div>
</div>
</div>
</div>
);
};
@@ -0,0 +1,268 @@
// ==============================================================================
// Modal de Ficha Técnica Completa de Persona
// Paridad 1:1 con DialogoFichaPersona (pct_view.py:435 - OneverAccess / OemspotPySYS)
// ==============================================================================
import React from 'react';
import { PersonPolicies, EntryFormData } from '../../types';
interface PersonProfileModalProps {
isOpen: boolean;
onClose: () => void;
personData: PersonPolicies | null;
formData?: EntryFormData;
}
export const PersonProfileModal: React.FC<PersonProfileModalProps> = ({
isOpen,
onClose,
personData,
formData,
}) => {
if (!isOpen) return null;
const doc = personData?.documento || formData?.documento || '-';
const ape = personData?.apellido || formData?.apellido || '';
const nom = personData?.nombre || formData?.nombre || '';
const nombreCompleto = `${ape} ${nom}`.trim() || 'Sin Nombre';
const sexo = personData?.sexo || formData?.sexo || 'M';
const entidad = formData?.entidad || '-';
const patente = formData?.patente || personData?.patente_sugerida || '-';
const rol = formData?.tipo_ingreso === 'CONDUCTOR' ? 'Conductor' : 'Peatón';
const rcNro = formData?.licencia_nro || personData?.licencia_nro || '-';
const rcEnt = formData?.licencia_entidad || personData?.licencia_entidad || '-';
const rcHasta = formData?.licencia_hasta || personData?.licencia_hasta || '-';
const psEmp = formData?.seguro_empresa || personData?.seguro_empresa || '-';
const psPol = formData?.seguro_poliza || personData?.seguro_poliza || '-';
const psHasta = formData?.seguro_hasta || personData?.seguro_hasta || '-';
const paEmp = formData?.art_empresa || personData?.art_empresa || '-';
const paPol = formData?.art_poliza || personData?.art_poliza || '-';
const paHasta = formData?.art_hasta || personData?.art_hasta || '-';
const obs = formData?.observaciones || personData?.observaciones || 'Sin observaciones registradas.';
const ticketActivoId = personData?.ticket_activo_id;
return (
<div
style={{
position: 'fixed',
inset: 0,
backgroundColor: 'rgba(0, 0, 0, 0.65)',
backdropFilter: 'blur(3px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1050,
padding: '1rem',
}}
onClick={(e) => {
if (e.target === e.currentTarget) onClose();
}}
>
<div
className="card"
style={{
width: '100%',
maxWidth: '680px',
maxHeight: '90vh',
display: 'flex',
flexDirection: 'column',
boxShadow: 'var(--shadow-xl)',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-md)',
backgroundColor: 'var(--bg-surface)',
overflow: 'hidden',
animation: 'fadeIn 0.15s ease-out',
}}
>
{/* Cabecera */}
<div
style={{
padding: '1rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem' }}>
<span style={{ fontSize: '1.4rem' }}>📇</span>
<div>
<h3 style={{ margin: 0, fontSize: '1.15rem', fontWeight: 800, color: 'var(--accent-primary)' }}>
FICHA TÉCNICA: {nombreCompleto}
</h3>
<p style={{ margin: 0, fontSize: '0.8rem', color: 'var(--text-secondary)' }}>
DNI {doc} • Sexo: {sexo} • Rol actual: {rol}
</p>
</div>
</div>
<button
type="button"
className="btn btn-secondary"
onClick={onClose}
style={{ minHeight: '36px', minWidth: '36px', padding: 0 }}
>
✕
</button>
</div>
{/* Alerta Antipassback si tiene ticket activo */}
{ticketActivoId && (
<div
style={{
padding: '0.65rem 1.25rem',
backgroundColor: 'rgba(239, 68, 68, 0.15)',
borderBottom: '1px solid rgba(239, 68, 68, 0.3)',
display: 'flex',
alignItems: 'center',
gap: '0.6rem',
color: '#ef4444',
fontSize: '0.85rem',
fontWeight: 600,
}}
>
<span>⚠️</span>
<span>
Esta persona registra Ticket Activo dentro del predio (#{ticketActivoId}) desde{' '}
{personData?.ticket_activo_fecha || 'fecha no disponible'}.
</span>
</div>
)}
{/* Contenido / Secciones */}
<div style={{ flex: 1, overflowY: 'auto', padding: '1.25rem', display: 'flex', flexDirection: 'column', gap: '1rem' }}>
{/* 1. Datos Generales y Vehículo */}
<div
style={{
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-sm)',
padding: '0.85rem 1rem',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--accent-primary)', marginBottom: '0.6rem', textTransform: 'uppercase' }}>
Identificación y Vínculo
</div>
<div style={{ display: 'grid', gridTemplateColumns: 'repeat(2, 1fr)', gap: '0.6rem', fontSize: '0.85rem' }}>
<div>
<span style={{ color: 'var(--text-secondary)' }}>Documento:</span>{' '}
<strong style={{ color: 'var(--text-primary)' }}>{doc}</strong>
</div>
<div>
<span style={{ color: 'var(--text-secondary)' }}>Entidad / Empresa:</span>{' '}
<strong style={{ color: 'var(--text-primary)' }}>{entidad}</strong>
</div>
<div>
<span style={{ color: 'var(--text-secondary)' }}>Patente Vehículo:</span>{' '}
<strong style={{ color: 'var(--text-primary)', fontFamily: 'monospace' }}>{patente}</strong>
</div>
<div>
<span style={{ color: 'var(--text-secondary)' }}>Patentes Registradas:</span>{' '}
<strong style={{ color: 'var(--text-primary)' }}>
{personData?.patentes_asociadas?.join(', ') || '-'}
</strong>
</div>
</div>
</div>
{/* 2. Coberturas y Licencias */}
<div
style={{
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-sm)',
padding: '0.85rem 1rem',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--accent-primary)', marginBottom: '0.6rem', textTransform: 'uppercase' }}>
Pólizas de Cobertura y Habilitaciones
</div>
<div style={{ display: 'flex', flexDirection: 'column', gap: '0.6rem', fontSize: '0.85rem' }}>
{/* Licencia de Conducir */}
<div style={{ display: 'flex', justifyContent: 'space-between', borderBottom: '1px dashed var(--border-subtle)', paddingBottom: '0.4rem' }}>
<div>
<strong style={{ color: 'var(--text-primary)' }}>Licencia / Registro Conductor:</strong>{' '}
<span style={{ color: 'var(--text-secondary)' }}>Nro {rcNro} ({rcEnt})</span>
</div>
<div style={{ color: rcHasta.includes('20') ? 'var(--text-primary)' : 'var(--text-muted)' }}>
Vence: <strong>{rcHasta}</strong>
</div>
</div>
{/* Seguro Automotor */}
<div style={{ display: 'flex', justifyContent: 'space-between', borderBottom: '1px dashed var(--border-subtle)', paddingBottom: '0.4rem' }}>
<div>
<strong style={{ color: 'var(--text-primary)' }}>Seguro Automotor:</strong>{' '}
<span style={{ color: 'var(--text-secondary)' }}>{psEmp} (Póliza {psPol})</span>
</div>
<div style={{ color: psHasta.includes('20') ? 'var(--text-primary)' : 'var(--text-muted)' }}>
Vence: <strong>{psHasta}</strong>
</div>
</div>
{/* ART */}
<div style={{ display: 'flex', justifyContent: 'space-between' }}>
<div>
<strong style={{ color: 'var(--text-primary)' }}>Seguro ART / Acc. Personales:</strong>{' '}
<span style={{ color: 'var(--text-secondary)' }}>{paEmp} (Póliza {paPol})</span>
</div>
<div style={{ color: paHasta.includes('20') ? 'var(--text-primary)' : 'var(--text-muted)' }}>
Vence: <strong>{paHasta}</strong>
</div>
</div>
</div>
</div>
{/* 3. Observaciones */}
<div
style={{
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-sm)',
padding: '0.85rem 1rem',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--accent-primary)', marginBottom: '0.4rem', textTransform: 'uppercase' }}>
Observaciones Registradas
</div>
<div
style={{
fontSize: '0.85rem',
color: 'var(--text-primary)',
fontStyle: obs === 'Sin observaciones registradas.' ? 'italic' : 'normal',
whiteSpace: 'pre-wrap',
lineHeight: '1.4',
}}
>
{obs}
</div>
</div>
</div>
{/* Footer */}
<div
style={{
padding: '1rem 1.25rem',
borderTop: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-app)',
display: 'flex',
justifyContent: 'flex-end',
}}
>
<button
type="button"
className="btn btn-primary"
onClick={onClose}
style={{ minHeight: '44px', padding: '0 2rem', fontWeight: 700 }}
>
Cerrar Ficha (ESC)
</button>
</div>
</div>
</div>
);
};
@@ -0,0 +1,337 @@
// ==============================================================================
// Modal de Búsqueda Avanzada de Personas
// Paridad 1:1 con DialogoBuscarPersona (pct_dialogs.py - OneverAccess / OemspotPySYS)
// ==============================================================================
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { PersonAdvancedSearchResult } from '../../types';
import { accessApi } from '../../api/accessApi';
interface PersonSearchModalProps {
isOpen: boolean;
onClose: () => void;
onSelect: (persona: PersonAdvancedSearchResult) => void;
initialSearch?: string;
}
export const PersonSearchModal: React.FC<PersonSearchModalProps> = ({
isOpen,
onClose,
onSelect,
initialSearch = '',
}) => {
const [query, setQuery] = useState<string>(initialSearch);
const [personas, setPersonas] = useState<PersonAdvancedSearchResult[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [selectedItem, setSelectedItem] = useState<PersonAdvancedSearchResult | null>(null);
const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const loadData = useCallback(async (searchTerm: string) => {
setIsLoading(true);
try {
const data = await accessApi.searchPeopleAdvanced(searchTerm, 50);
setPersonas(data);
if (data.length > 0) {
setSelectedItem((prev) => (prev ? (data.find((p) => p.PersonaID === prev.PersonaID) || data[0]) : data[0]));
} else {
setSelectedItem(null);
}
} catch (e) {
console.error('Error al buscar personas:', e);
setPersonas([]);
setSelectedItem(null);
} finally {
setIsLoading(false);
}
}, []);
useEffect(() => {
if (isOpen) {
setQuery(initialSearch);
loadData(initialSearch);
} else {
setQuery('');
setSelectedItem(null);
}
}, [isOpen, initialSearch, loadData]);
const handleQueryChange = (text: string) => {
setQuery(text);
if (searchTimerRef.current) {
clearTimeout(searchTimerRef.current);
}
searchTimerRef.current = setTimeout(() => {
loadData(text);
}, 250);
};
const handleConfirm = (item?: PersonAdvancedSearchResult | null) => {
const target = item || selectedItem;
if (!target) return;
onSelect(target);
onClose();
};
if (!isOpen) return null;
return (
<div
style={{
position: 'fixed',
inset: 0,
backgroundColor: 'rgba(0, 0, 0, 0.65)',
backdropFilter: 'blur(3px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1050,
padding: '1rem',
}}
onClick={(e) => {
if (e.target === e.currentTarget) onClose();
}}
>
<div
className="card"
style={{
width: '100%',
maxWidth: '850px',
maxHeight: '90vh',
display: 'flex',
flexDirection: 'column',
boxShadow: 'var(--shadow-xl)',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-md)',
backgroundColor: 'var(--bg-surface)',
overflow: 'hidden',
animation: 'fadeIn 0.15s ease-out',
}}
>
{/* Header */}
<div
style={{
padding: '1rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem' }}>
<span style={{ fontSize: '1.4rem' }}>👤</span>
<div>
<h3 style={{ margin: 0, fontSize: '1.15rem', fontWeight: 700, color: 'var(--text-primary)' }}>
Búsqueda Avanzada de Personas
</h3>
<p style={{ margin: 0, fontSize: '0.8rem', color: 'var(--text-secondary)' }}>
Búsqueda por Documento, Nombre, Apellido, Nro de Socio o Lote vinculado.
</p>
</div>
</div>
<button
type="button"
className="btn btn-secondary"
onClick={onClose}
style={{ minHeight: '36px', minWidth: '36px', padding: 0 }}
>
✕
</button>
</div>
{/* Input de Búsqueda */}
<div
style={{
padding: '0.85rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-surface)',
display: 'flex',
gap: '0.75rem',
alignItems: 'center',
}}
>
<div style={{ flex: 1, position: 'relative' }}>
<input
type="text"
className="input-field"
placeholder="🔍 Escriba Documento, Apellido o Nombre..."
value={query}
onChange={(e) => handleQueryChange(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') loadData(query);
}}
autoFocus
style={{ paddingRight: query ? '2.5rem' : '1rem', minHeight: '42px' }}
/>
{query && (
<button
type="button"
onClick={() => handleQueryChange('')}
style={{
position: 'absolute',
right: '0.75rem',
top: '50%',
transform: 'translateY(-50%)',
background: 'none',
border: 'none',
color: 'var(--text-muted)',
cursor: 'pointer',
fontSize: '1rem',
}}
>
✕
</button>
)}
</div>
<button
type="button"
className="btn btn-primary"
onClick={() => loadData(query)}
style={{ minHeight: '42px', padding: '0 1.25rem', fontWeight: 600 }}
>
Buscar
</button>
</div>
{/* Tabla */}
<div style={{ flex: 1, overflowY: 'auto', padding: '0.5rem 1.25rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', margin: '0.4rem 0' }}>
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-secondary)', textTransform: 'uppercase' }}>
Personas Encontradas ({personas.length}) {isLoading && '• Buscando...'}
</span>
<span style={{ fontSize: '0.75rem', color: 'var(--text-muted)' }}>
Doble clic para seleccionar y cargar
</span>
</div>
<div
style={{
maxHeight: '400px',
overflowY: 'auto',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-sm)',
backgroundColor: 'var(--bg-app)',
}}
>
{personas.length === 0 && !isLoading ? (
<div style={{ padding: '2rem', textAlign: 'center', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
No se encontraron personas con los criterios de búsqueda ingresados.
</div>
) : (
<table style={{ width: '100%', borderCollapse: 'collapse', textAlign: 'left', fontSize: '0.85rem' }}>
<thead>
<tr style={{ backgroundColor: 'var(--bg-surface)', borderBottom: '1px solid var(--border-subtle)' }}>
<th style={{ padding: '0.55rem 0.75rem', width: '120px' }}>Documento</th>
<th style={{ padding: '0.55rem 0.75rem' }}>Apellido</th>
<th style={{ padding: '0.55rem 0.75rem' }}>Nombre</th>
<th style={{ padding: '0.55rem 0.75rem', width: '100px' }}>Nro Socio</th>
<th style={{ padding: '0.55rem 0.75rem', width: '130px' }}>Estado / Alerta</th>
</tr>
</thead>
<tbody>
{personas.map((p) => {
const isSel = selectedItem?.PersonaID === p.PersonaID;
const isBlacklist = p.Blacklist === 1;
return (
<tr
key={p.PersonaID}
onClick={() => setSelectedItem(p)}
onDoubleClick={() => handleConfirm(p)}
style={{
cursor: 'pointer',
backgroundColor: isSel ? 'rgba(37, 99, 235, 0.18)' : 'transparent',
borderBottom: '1px solid var(--border-subtle)',
fontWeight: isSel ? 700 : 400,
borderLeft: isSel ? '4px solid var(--accent-primary)' : '4px solid transparent',
transition: 'background 0.1s ease',
}}
>
<td style={{ padding: '0.55rem 0.75rem' }}>
<strong style={{ color: 'var(--text-primary)' }}>{p.Documento || '-'}</strong>
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
{p.Apellido}
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
{p.Nombre}
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-secondary)' }}>
{p.NroSocio || '-'}
</td>
<td style={{ padding: '0.55rem 0.75rem' }}>
{isBlacklist ? (
<span
style={{
padding: '0.2rem 0.5rem',
borderRadius: '4px',
fontSize: '0.75rem',
fontWeight: 700,
backgroundColor: 'rgba(239, 68, 68, 0.2)',
color: '#ef4444',
}}
>
⛔ LISTA NEGRA
</span>
) : (
<span
style={{
padding: '0.2rem 0.5rem',
borderRadius: '4px',
fontSize: '0.75rem',
fontWeight: 600,
backgroundColor: 'rgba(16, 185, 129, 0.15)',
color: '#10b981',
}}
>
✔ Habilitado
</span>
)}
</td>
</tr>
);
})}
</tbody>
</table>
)}
</div>
</div>
{/* Footer */}
<div
style={{
padding: '1rem 1.25rem',
borderTop: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-app)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<div style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}>
{selectedItem ? (
<span>
Seleccionado: <strong>{selectedItem.Apellido}, {selectedItem.Nombre}</strong> ({selectedItem.Documento})
</span>
) : (
'Ninguna persona seleccionada'
)}
</div>
<div style={{ display: 'flex', gap: '0.75rem' }}>
<button type="button" className="btn btn-secondary" onClick={onClose} style={{ minHeight: '44px', padding: '0 1.25rem' }}>
Cancelar
</button>
<button
type="button"
className="btn btn-primary"
disabled={!selectedItem}
onClick={() => handleConfirm()}
style={{ minHeight: '44px', padding: '0 1.5rem', fontWeight: 700 }}
>
✔ Seleccionar Persona
</button>
</div>
</div>
</div>
</div>
);
};
@@ -0,0 +1,352 @@
// ==============================================================================
// Modal de Visitas Preautorizadas (Invitados)
// Paridad 1:1 con DialogoBuscarPreautorizados (pct_dialogs.py - OneverAccess / OemspotPySYS)
// ==============================================================================
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { Preauthorization } from '../../types';
import { accessApi } from '../../api/accessApi';
interface PreauthorizedModalProps {
isOpen: boolean;
onClose: () => void;
onSelect: (preaut: Preauthorization) => void;
initialSearch?: string;
}
export const PreauthorizedModal: React.FC<PreauthorizedModalProps> = ({
isOpen,
onClose,
onSelect,
initialSearch = '',
}) => {
const [query, setQuery] = useState<string>(initialSearch);
const [soloVigentes, setSoloVigentes] = useState<boolean>(true);
const [preautorizados, setPreautorizados] = useState<Preauthorization[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [selectedItem, setSelectedItem] = useState<Preauthorization | null>(null);
const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const loadData = useCallback(async (searchTerm: string, vigentes: boolean) => {
setIsLoading(true);
try {
const data = await accessApi.getPreauthorizations(searchTerm, vigentes);
setPreautorizados(data);
if (data.length > 0) {
setSelectedItem((prev) => (prev ? (data.find((p) => p.id === prev.id) || data[0]) : data[0]));
} else {
setSelectedItem(null);
}
} catch (e) {
console.error('Error al cargar preautorizados:', e);
setPreautorizados([]);
setSelectedItem(null);
} finally {
setIsLoading(false);
}
}, []);
useEffect(() => {
if (isOpen) {
setQuery(initialSearch);
loadData(initialSearch, soloVigentes);
} else {
setQuery('');
setSelectedItem(null);
}
}, [isOpen, initialSearch, loadData, soloVigentes]);
const handleQueryChange = (text: string) => {
setQuery(text);
if (searchTimerRef.current) {
clearTimeout(searchTimerRef.current);
}
searchTimerRef.current = setTimeout(() => {
loadData(text, soloVigentes);
}, 250);
};
const handleToggleVigentes = (e: React.ChangeEvent<HTMLSelectElement>) => {
const val = e.target.value === 'vigentes';
setSoloVigentes(val);
loadData(query, val);
};
const handleConfirm = (item?: Preauthorization | null) => {
const target = item || selectedItem;
if (!target) return;
onSelect(target);
onClose();
};
if (!isOpen) return null;
return (
<div
style={{
position: 'fixed',
inset: 0,
backgroundColor: 'rgba(0, 0, 0, 0.65)',
backdropFilter: 'blur(3px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1050,
padding: '1rem',
}}
onClick={(e) => {
if (e.target === e.currentTarget) onClose();
}}
>
<div
className="card"
style={{
width: '100%',
maxWidth: '920px',
maxHeight: '90vh',
display: 'flex',
flexDirection: 'column',
boxShadow: 'var(--shadow-xl)',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-md)',
backgroundColor: 'var(--bg-surface)',
overflow: 'hidden',
animation: 'fadeIn 0.15s ease-out',
}}
>
{/* Cabecera */}
<div
style={{
padding: '1rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem' }}>
<span style={{ fontSize: '1.4rem' }}>📋</span>
<div>
<h3 style={{ margin: 0, fontSize: '1.15rem', fontWeight: 700, color: 'var(--text-primary)' }}>
Visitas Preautorizadas (Invitados)
</h3>
<p style={{ margin: 0, fontSize: '0.8rem', color: 'var(--text-secondary)' }}>
Seleccione un visitante preautorizado para precargar datos y lote al carril de entrada.
</p>
</div>
</div>
<button
type="button"
className="btn btn-secondary"
onClick={onClose}
style={{ minHeight: '36px', minWidth: '36px', padding: 0 }}
>
✕
</button>
</div>
{/* Filtros */}
<div
style={{
padding: '0.85rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-surface)',
display: 'flex',
gap: '0.75rem',
alignItems: 'center',
}}
>
<div style={{ flex: 1, position: 'relative' }}>
<input
type="text"
className="input-field"
placeholder="🔍 Filtrar por Visitante, Lote, Entidad o Documento..."
value={query}
onChange={(e) => handleQueryChange(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') loadData(query, soloVigentes);
}}
autoFocus
style={{ paddingRight: query ? '2.5rem' : '1rem', minHeight: '42px' }}
/>
{query && (
<button
type="button"
onClick={() => handleQueryChange('')}
style={{
position: 'absolute',
right: '0.75rem',
top: '50%',
transform: 'translateY(-50%)',
background: 'none',
border: 'none',
color: 'var(--text-muted)',
cursor: 'pointer',
fontSize: '1rem',
}}
>
✕
</button>
)}
</div>
<select
className="input-field"
value={soloVigentes ? 'vigentes' : 'todas'}
onChange={handleToggleVigentes}
style={{ width: '180px', minHeight: '42px', fontWeight: 600 }}
>
<option value="vigentes">Vigentes Hoy</option>
<option value="todas">Todas las Fechas</option>
</select>
<button
type="button"
className="btn btn-primary"
onClick={() => loadData(query, soloVigentes)}
style={{ minHeight: '42px', padding: '0 1.25rem', fontWeight: 600 }}
>
Filtrar
</button>
</div>
{/* Tabla */}
<div style={{ flex: 1, overflowY: 'auto', padding: '0.5rem 1.25rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', margin: '0.4rem 0' }}>
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-secondary)', textTransform: 'uppercase' }}>
Resultados ({preautorizados.length}) {isLoading && '• Cargando...'}
</span>
<span style={{ fontSize: '0.75rem', color: 'var(--text-muted)' }}>
Doble clic para cargar al carril
</span>
</div>
<div
style={{
maxHeight: '400px',
overflowY: 'auto',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-sm)',
backgroundColor: 'var(--bg-app)',
}}
>
{preautorizados.length === 0 && !isLoading ? (
<div style={{ padding: '2rem', textAlign: 'center', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
No hay visitas preautorizadas registradas con los filtros seleccionados.
</div>
) : (
<table style={{ width: '100%', borderCollapse: 'collapse', textAlign: 'left', fontSize: '0.85rem' }}>
<thead>
<tr style={{ backgroundColor: 'var(--bg-surface)', borderBottom: '1px solid var(--border-subtle)' }}>
<th style={{ padding: '0.55rem 0.75rem', width: '70px' }}>ID</th>
<th style={{ padding: '0.55rem 0.75rem', width: '110px' }}>Lote</th>
<th style={{ padding: '0.55rem 0.75rem' }}>Visitante</th>
<th style={{ padding: '0.55rem 0.75rem', width: '110px' }}>Documento</th>
<th style={{ padding: '0.55rem 0.75rem' }}>Entidad / Empresa</th>
<th style={{ padding: '0.55rem 0.75rem', width: '140px' }}>Vigencia</th>
</tr>
</thead>
<tbody>
{preautorizados.map((p) => {
const isSel = selectedItem?.id === p.id;
const nombreCompleto = `${p.apellido}, ${p.nombre}`.trim() || 'Sin Nombre';
return (
<tr
key={p.id}
onClick={() => setSelectedItem(p)}
onDoubleClick={() => handleConfirm(p)}
style={{
cursor: 'pointer',
backgroundColor: isSel ? 'rgba(37, 99, 235, 0.18)' : 'transparent',
borderBottom: '1px solid var(--border-subtle)',
fontWeight: isSel ? 700 : 400,
borderLeft: isSel ? '4px solid var(--accent-primary)' : '4px solid transparent',
transition: 'background 0.1s ease',
}}
>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-muted)' }}>#{p.id}</td>
<td style={{ padding: '0.55rem 0.75rem' }}>
<span
style={{
padding: '0.15rem 0.4rem',
borderRadius: '4px',
backgroundColor: 'rgba(59, 130, 246, 0.15)',
color: 'var(--accent-primary)',
fontWeight: 700,
}}
>
Lote {p.lote_nombre}
</span>
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
<strong>{nombreCompleto}</strong>
{p.motivo && p.motivo !== p.documento && (
<div style={{ fontSize: '0.75rem', color: 'var(--text-secondary)' }}>{p.motivo}</div>
)}
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
{p.documento || <span style={{ color: 'var(--text-muted)' }}>-</span>}
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-secondary)' }}>
{p.entidad || '-'}
</td>
<td style={{ padding: '0.55rem 0.75rem', fontSize: '0.78rem', color: 'var(--text-secondary)' }}>
<div>{p.fecha_inicio ? p.fecha_inicio.slice(0, 10) : ''}</div>
<div style={{ color: 'var(--text-muted)' }}>hasta {p.fecha_fin ? p.fecha_fin.slice(0, 10) : ''}</div>
</td>
</tr>
);
})}
</tbody>
</table>
)}
</div>
</div>
{/* Footer */}
<div
style={{
padding: '1rem 1.25rem',
borderTop: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-app)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<div style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}>
{selectedItem ? (
<span>
Seleccionado: <strong>{selectedItem.apellido}, {selectedItem.nombre}</strong> (Lote {selectedItem.lote_nombre})
</span>
) : (
'Ningún visitante seleccionado'
)}
</div>
<div style={{ display: 'flex', gap: '0.75rem' }}>
<button type="button" className="btn btn-secondary" onClick={onClose} style={{ minHeight: '44px', padding: '0 1.25rem' }}>
Cerrar
</button>
<button
type="button"
className="btn btn-success"
disabled={!selectedItem}
onClick={() => handleConfirm()}
style={{
minHeight: '44px',
padding: '0 1.5rem',
fontWeight: 700,
backgroundColor: '#10b981',
color: '#ffffff',
border: 'none',
}}
>
📋 Cargar al Carril de Entrada
</button>
</div>
</div>
</div>
</div>
);
};
@@ -0,0 +1,359 @@
// ==============================================================================
// Modal de Búsqueda Predictiva de Vehículos por Patente
// Paridad 1:1 con DialogoBuscarPatente (pct_dialogs.py - OneverAccess / OemspotPySYS)
// ==============================================================================
import React, { useState, useEffect, useRef, useCallback } from 'react';
import { VehicleSearchResult } from '../../types';
import { accessApi } from '../../api/accessApi';
interface VehicleSearchModalProps {
isOpen: boolean;
onClose: () => void;
onSelect: (vehiculo: VehicleSearchResult) => void;
esSalida?: boolean;
initialSearch?: string;
}
export const VehicleSearchModal: React.FC<VehicleSearchModalProps> = ({
isOpen,
onClose,
onSelect,
esSalida = false,
initialSearch = '',
}) => {
const [query, setQuery] = useState<string>(initialSearch);
const [vehiculos, setVehiculos] = useState<VehicleSearchResult[]>([]);
const [isLoading, setIsLoading] = useState<boolean>(false);
const [selectedItem, setSelectedItem] = useState<VehicleSearchResult | null>(null);
const searchTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const loadData = useCallback(async (searchTerm: string) => {
setIsLoading(true);
try {
const data = await accessApi.searchVehicles(searchTerm, esSalida, 50);
setVehiculos(data);
if (data.length > 0) {
setSelectedItem((prev) => (prev ? (data.find((v) => v.patente === prev.patente) || data[0]) : data[0]));
} else {
setSelectedItem(null);
}
} catch (e) {
console.error('Error al buscar vehículos:', e);
setVehiculos([]);
setSelectedItem(null);
} finally {
setIsLoading(false);
}
}, [esSalida]);
useEffect(() => {
if (isOpen) {
const initUpper = (initialSearch || '').toUpperCase().trim();
setQuery(initUpper);
loadData(initUpper);
} else {
setQuery('');
setSelectedItem(null);
}
}, [isOpen, initialSearch, loadData]);
const handleQueryChange = (text: string) => {
const upper = text.toUpperCase();
setQuery(upper);
if (searchTimerRef.current) {
clearTimeout(searchTimerRef.current);
}
searchTimerRef.current = setTimeout(() => {
loadData(upper);
}, 250);
};
const handleConfirm = (item?: VehicleSearchResult | null) => {
const target = item || selectedItem;
if (!target) return;
onSelect(target);
onClose();
};
if (!isOpen) return null;
const tituloModo = esSalida ? 'Salida (Vehículos en Predio)' : 'Entrada (Padrón de Vehículos)';
return (
<div
style={{
position: 'fixed',
inset: 0,
backgroundColor: 'rgba(0, 0, 0, 0.65)',
backdropFilter: 'blur(3px)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
zIndex: 1050,
padding: '1rem',
}}
onClick={(e) => {
if (e.target === e.currentTarget) onClose();
}}
>
<div
className="card"
style={{
width: '100%',
maxWidth: '880px',
maxHeight: '90vh',
display: 'flex',
flexDirection: 'column',
boxShadow: 'var(--shadow-xl)',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-md)',
backgroundColor: 'var(--bg-surface)',
overflow: 'hidden',
animation: 'fadeIn 0.15s ease-out',
}}
>
{/* Header */}
<div
style={{
padding: '1rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
backgroundColor: 'var(--bg-app)',
}}
>
<div style={{ display: 'flex', alignItems: 'center', gap: '0.6rem' }}>
<span style={{ fontSize: '1.4rem' }}>🚗</span>
<div>
<h3 style={{ margin: 0, fontSize: '1.15rem', fontWeight: 700, color: 'var(--text-primary)' }}>
Búsqueda de Vehículos por Patente — {tituloModo}
</h3>
<p style={{ margin: 0, fontSize: '0.8rem', color: 'var(--text-secondary)' }}>
{esSalida
? 'Filtre por patente, conductor o lote para seleccionar vehículos con ticket activo.'
: 'Filtre en el padrón de automotores registrados con datos de pólizas y titulares.'}
</p>
</div>
</div>
<button
type="button"
className="btn btn-secondary"
onClick={onClose}
style={{ minHeight: '36px', minWidth: '36px', padding: 0 }}
>
✕
</button>
</div>
{/* Input de Búsqueda */}
<div
style={{
padding: '0.85rem 1.25rem',
borderBottom: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-surface)',
display: 'flex',
gap: '0.75rem',
alignItems: 'center',
}}
>
<div style={{ flex: 1, position: 'relative' }}>
<input
type="text"
className="input-field"
placeholder="🔍 Escriba parte de la patente, titular, modelo o DNI..."
value={query}
onChange={(e) => handleQueryChange(e.target.value)}
onKeyDown={(e) => {
if (e.key === 'Enter') loadData(query);
}}
autoFocus
style={{
paddingRight: query ? '2.5rem' : '1rem',
minHeight: '42px',
textTransform: 'uppercase',
fontWeight: 600,
letterSpacing: '1px',
}}
/>
{query && (
<button
type="button"
onClick={() => handleQueryChange('')}
style={{
position: 'absolute',
right: '0.75rem',
top: '50%',
transform: 'translateY(-50%)',
background: 'none',
border: 'none',
color: 'var(--text-muted)',
cursor: 'pointer',
fontSize: '1rem',
}}
>
✕
</button>
)}
</div>
<button
type="button"
className="btn btn-primary"
onClick={() => loadData(query)}
style={{ minHeight: '42px', padding: '0 1.25rem', fontWeight: 600 }}
>
Buscar
</button>
</div>
{/* Tabla */}
<div style={{ flex: 1, overflowY: 'auto', padding: '0.5rem 1.25rem' }}>
<div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', margin: '0.4rem 0' }}>
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-secondary)', textTransform: 'uppercase' }}>
Coincidencias ({vehiculos.length}) {isLoading && '• Buscando...'}
</span>
<span style={{ fontSize: '0.75rem', color: 'var(--text-muted)' }}>
Doble clic para cargar al formulario
</span>
</div>
<div
style={{
maxHeight: '400px',
overflowY: 'auto',
border: '1px solid var(--border-subtle)',
borderRadius: 'var(--radius-sm)',
backgroundColor: 'var(--bg-app)',
}}
>
{vehiculos.length === 0 && !isLoading ? (
<div style={{ padding: '2rem', textAlign: 'center', color: 'var(--text-secondary)', fontSize: '0.9rem' }}>
No se encontraron vehículos coincidentes con los filtros especificados.
</div>
) : (
<table style={{ width: '100%', borderCollapse: 'collapse', textAlign: 'left', fontSize: '0.85rem' }}>
<thead>
<tr style={{ backgroundColor: 'var(--bg-surface)', borderBottom: '1px solid var(--border-subtle)' }}>
<th style={{ padding: '0.55rem 0.75rem', width: '110px' }}>Patente</th>
<th style={{ padding: '0.55rem 0.75rem' }}>Marca / Modelo</th>
<th style={{ padding: '0.55rem 0.75rem' }}>Conductor / Titular</th>
<th style={{ padding: '0.55rem 0.75rem', width: '110px' }}>DNI</th>
{esSalida ? (
<>
<th style={{ padding: '0.55rem 0.75rem', width: '110px' }}>Lote</th>
<th style={{ padding: '0.55rem 0.75rem', width: '130px' }}>Ingreso</th>
</>
) : (
<th style={{ padding: '0.55rem 0.75rem', width: '130px' }}>Vigencia Seguro</th>
)}
</tr>
</thead>
<tbody>
{vehiculos.map((v, idx) => {
const isSel = selectedItem?.patente === v.patente;
const nombreCompleto = `${v.apellido} ${v.nombre}`.trim() || '-';
const marcaModelo = `${v.marca} ${v.modelo}`.trim() || '-';
return (
<tr
key={`${v.patente}-${v.ticket_id || idx}`}
onClick={() => setSelectedItem(v)}
onDoubleClick={() => handleConfirm(v)}
style={{
cursor: 'pointer',
backgroundColor: isSel ? 'rgba(37, 99, 235, 0.18)' : 'transparent',
borderBottom: '1px solid var(--border-subtle)',
fontWeight: isSel ? 700 : 400,
borderLeft: isSel ? '4px solid var(--accent-primary)' : '4px solid transparent',
transition: 'background 0.1s ease',
}}
>
<td style={{ padding: '0.55rem 0.75rem' }}>
<span
style={{
display: 'inline-block',
padding: '0.2rem 0.5rem',
borderRadius: '4px',
backgroundColor: 'rgba(37, 99, 235, 0.15)',
color: 'var(--accent-primary)',
fontWeight: 800,
fontFamily: 'monospace',
fontSize: '0.95rem',
}}
>
{v.patente}
</span>
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
{marcaModelo}
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-primary)' }}>
{nombreCompleto}
</td>
<td style={{ padding: '0.55rem 0.75rem', color: 'var(--text-secondary)' }}>
{v.documento || '-'}
</td>
{esSalida ? (
<>
<td style={{ padding: '0.55rem 0.75rem' }}>
<span style={{ fontWeight: 600, color: 'var(--text-primary)' }}>
{v.lote ? `Lote ${v.lote}` : '-'}
</span>
</td>
<td style={{ padding: '0.55rem 0.75rem', fontSize: '0.78rem', color: 'var(--text-secondary)' }}>
{v.fecha_ingreso || '-'}
</td>
</>
) : (
<td style={{ padding: '0.55rem 0.75rem', fontSize: '0.8rem', color: 'var(--text-secondary)' }}>
{v.vigencia_seguro ? v.vigencia_seguro.slice(0, 10) : '-'}
</td>
)}
</tr>
);
})}
</tbody>
</table>
)}
</div>
</div>
{/* Footer */}
<div
style={{
padding: '1rem 1.25rem',
borderTop: '1px solid var(--border-subtle)',
backgroundColor: 'var(--bg-app)',
display: 'flex',
justifyContent: 'space-between',
alignItems: 'center',
}}
>
<div style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}>
{selectedItem ? (
<span>
Seleccionado: <strong>{selectedItem.patente}</strong> ({selectedItem.marca} {selectedItem.modelo})
</span>
) : (
'Ningún vehículo seleccionado'
)}
</div>
<div style={{ display: 'flex', gap: '0.75rem' }}>
<button type="button" className="btn btn-secondary" onClick={onClose} style={{ minHeight: '44px', padding: '0 1.25rem' }}>
Cancelar
</button>
<button
type="button"
className="btn btn-primary"
disabled={!selectedItem}
onClick={() => handleConfirm()}
style={{ minHeight: '44px', padding: '0 1.5rem', fontWeight: 700 }}
>
✔ Seleccionar Patente
</button>
</div>
</div>
</div>
</div>
);
};
+78
View File
@@ -66,6 +66,7 @@ export interface EntryFormData {
licencia_hasta?: string;
observaciones?: string;
forzar_ingreso_lote_restringido?: boolean;
preautorizado_id?: number | null;
}
export interface PersonPolicies {
@@ -88,6 +89,9 @@ export interface PersonPolicies {
licencia_entidad?: string | null;
licencia_hasta?: string | null;
observaciones?: string | null;
ticket_activo_id?: number | null;
ticket_activo_modulo_ingreso?: string | null;
ticket_activo_fecha?: string | null;
}
export interface VehicleDetails {
@@ -100,6 +104,25 @@ export interface VehicleDetails {
apellido?: string | null;
nombre?: string | null;
documento?: string | null;
ticket_activo_id?: number | null;
}
export interface ScanHistoryItem {
documento: string;
apellido: string;
nombre: string;
sexo: string;
patente?: string;
hora: string;
}
export interface LanePendingSession {
moduleId: number;
form: EntryFormData;
integrantes: Companion[];
totalAdultos: number;
totalMenores: number;
timestamp: string;
}
@@ -140,6 +163,10 @@ export interface ActiveTicket {
nombre: string;
patente?: string | null;
lote_codigo?: string | null;
lote_id?: number | null;
lote_nombre?: string | null;
entidad?: string | null;
rol_id?: number | null;
modulo_ingreso: string;
fecha_ingreso: string;
ocupantes: number;
@@ -202,3 +229,54 @@ export interface RecentMovement {
fecha_hora: string;
entidad?: string | null;
}
export interface Preauthorization {
id: number;
lote_id: number;
lote_nombre: string;
entidad: string;
apellido: string;
nombre: string;
documento: string;
motivo: string;
fecha_inicio: string;
fecha_fin: string;
}
export interface VehicleSearchResult {
patente: string;
marca: string;
modelo: string;
apellido: string;
nombre: string;
documento: string;
lote: string;
fecha_ingreso: string;
vigencia_seguro: string;
ticket_id?: number | null;
}
export interface PersonAdvancedSearchResult {
PersonaID: number;
Apellido: string;
Nombre: string;
NroSocio?: string | number | null;
Blacklist: number;
Documento?: string | null;
}
export interface MassExitRequest {
ticket_ids: number[];
modulo_salida_id: number;
motivo: string;
observaciones?: string;
password_operador?: string;
}
export interface MassExitResult {
status: string;
egresados_count: number;
message: string;
salida_masiva_id: number;
}
+2 -2
View File
@@ -1,6 +1,6 @@
// ==============================================================================
// Información de Versión y Build de OnEverControl (OnEverAccess)
// ==============================================================================
export const APP_VERSION = 'v0.6.2';
export const APP_BUILD = 'Build 2026.10.14';
export const APP_VERSION = 'v0.7.0-beta';
export const APP_BUILD = 'Build 2026.10.29';
export const APP_NAME = 'OnEver Access · Control Web';
File diff suppressed because it is too large Load Diff