feat(puesto-control): paridad total de validaciones, seguro automotor, ART y UX tablet 9-11 pulgadas
This commit is contained in:
@@ -69,5 +69,18 @@ export const accessApi = {
|
||||
method: 'GET',
|
||||
});
|
||||
},
|
||||
|
||||
getPersonDetails: (documento: string) => {
|
||||
return request<import('../types').PersonPolicies>(`/access/people/${encodeURIComponent(documento)}/details`, {
|
||||
method: 'GET',
|
||||
});
|
||||
},
|
||||
|
||||
getVehicleDetails: (patente: string) => {
|
||||
return request<import('../types').VehicleDetails>(`/access/vehicles/${encodeURIComponent(patente)}/details`, {
|
||||
method: 'GET',
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
|
||||
@@ -38,17 +38,67 @@ export interface EntryFormData {
|
||||
apellido: string;
|
||||
nombre: string;
|
||||
sexo: string;
|
||||
tipo_ingreso: 'CONDUCTOR' | 'PEATON';
|
||||
patente: string;
|
||||
lote_id?: number | null;
|
||||
lote_codigo: string;
|
||||
motivo: string;
|
||||
entidad?: string;
|
||||
cantidad_ocupantes: number;
|
||||
cantidad_menores: number;
|
||||
cacheo_salida: boolean;
|
||||
abrir_barrera: boolean;
|
||||
integrantes: Companion[];
|
||||
seguro_empresa?: string;
|
||||
seguro_poliza?: string;
|
||||
seguro_desde?: string;
|
||||
seguro_hasta?: string;
|
||||
art_empresa?: string;
|
||||
art_poliza?: string;
|
||||
art_desde?: string;
|
||||
art_hasta?: string;
|
||||
licencia_nro?: string;
|
||||
licencia_entidad?: string;
|
||||
licencia_hasta?: string;
|
||||
observaciones?: string;
|
||||
forzar_ingreso_lote_restringido?: boolean;
|
||||
}
|
||||
|
||||
export interface PersonPolicies {
|
||||
persona_id: number;
|
||||
documento: string;
|
||||
apellido: string;
|
||||
nombre: string;
|
||||
sexo: string;
|
||||
patente_sugerida?: string | null;
|
||||
patentes_asociadas: string[];
|
||||
seguro_empresa?: string | null;
|
||||
seguro_poliza?: string | null;
|
||||
seguro_desde?: string | null;
|
||||
seguro_hasta?: string | null;
|
||||
art_empresa?: string | null;
|
||||
art_poliza?: string | null;
|
||||
art_desde?: string | null;
|
||||
art_hasta?: string | null;
|
||||
licencia_nro?: string | null;
|
||||
licencia_entidad?: string | null;
|
||||
licencia_hasta?: string | null;
|
||||
observaciones?: string | null;
|
||||
}
|
||||
|
||||
export interface VehicleDetails {
|
||||
patente: string;
|
||||
aseguradora?: string | null;
|
||||
poliza_nro?: string | null;
|
||||
vigencia_desde?: string | null;
|
||||
vigencia_hasta?: string | null;
|
||||
persona_id?: number | null;
|
||||
apellido?: string | null;
|
||||
nombre?: string | null;
|
||||
documento?: string | null;
|
||||
}
|
||||
|
||||
|
||||
export interface LotPermission {
|
||||
estado: string;
|
||||
color: string;
|
||||
|
||||
@@ -46,17 +46,37 @@ export const ControlPostView: React.FC = () => {
|
||||
apellido: '',
|
||||
nombre: '',
|
||||
sexo: 'M',
|
||||
tipo_ingreso: 'CONDUCTOR',
|
||||
patente: '',
|
||||
lote_id: null,
|
||||
lote_codigo: '',
|
||||
motivo: 'VISITA',
|
||||
entidad: '',
|
||||
cantidad_ocupantes: 1,
|
||||
cantidad_menores: 0,
|
||||
cacheo_salida: false,
|
||||
abrir_barrera: true,
|
||||
integrantes: [],
|
||||
seguro_empresa: '',
|
||||
seguro_poliza: '',
|
||||
seguro_desde: '',
|
||||
seguro_hasta: '',
|
||||
art_empresa: '',
|
||||
art_poliza: '',
|
||||
art_desde: '',
|
||||
art_hasta: '',
|
||||
licencia_nro: '',
|
||||
licencia_entidad: '',
|
||||
licencia_hasta: '',
|
||||
observaciones: '',
|
||||
forzar_ingreso_lote_restringido: false,
|
||||
});
|
||||
|
||||
const [associatedPatentes, setAssociatedPatentes] = useState<string[]>([]);
|
||||
const [showPoliciesSection, setShowPoliciesSection] = useState<boolean>(true);
|
||||
const [confirmRestrictedModal, setConfirmRestrictedModal] = useState<boolean>(false);
|
||||
|
||||
|
||||
// Autocompletado y validación de Lotes
|
||||
const [lotSuggestions, setLotSuggestions] = useState<LotSearchItem[]>([]);
|
||||
const [showLotSuggestions, setShowLotSuggestions] = useState<boolean>(false);
|
||||
@@ -208,6 +228,97 @@ export const ControlPostView: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
// Evaluación de vigencia de pólizas (Paridad pct_view.py)
|
||||
const getPolicyStatus = (dateStr?: string) => {
|
||||
if (!dateStr || dateStr === '1900-01-01' || dateStr === '-' || !dateStr.trim()) {
|
||||
return { status: 'missing', label: 'Sin Cargar', color: '#ff9800', bg: 'rgba(255, 152, 0, 0.15)', border: '#ff9800' };
|
||||
}
|
||||
const clean = dateStr.split(' ')[0].replace(/\//g, '-');
|
||||
let dt: Date | null = null;
|
||||
const parts = clean.split('-');
|
||||
if (parts.length === 3) {
|
||||
if (parts[0].length === 4) {
|
||||
dt = new Date(Number(parts[0]), Number(parts[1]) - 1, Number(parts[2]));
|
||||
} else {
|
||||
dt = new Date(Number(parts[2]), Number(parts[1]) - 1, Number(parts[0]));
|
||||
}
|
||||
}
|
||||
if (!dt || isNaN(dt.getTime())) {
|
||||
return { status: 'invalid', label: 'Inválida', color: '#f44336', bg: 'rgba(244, 67, 54, 0.15)', border: '#f44336' };
|
||||
}
|
||||
const today = new Date();
|
||||
today.setHours(0, 0, 0, 0);
|
||||
if (dt < today) {
|
||||
return { status: 'expired', label: 'VENCIDA', color: '#f44336', bg: 'rgba(244, 67, 54, 0.2)', border: '#f44336' };
|
||||
}
|
||||
return { status: 'valid', label: 'VIGENTE', color: '#4caf50', bg: 'rgba(76, 175, 80, 0.15)', border: '#4caf50' };
|
||||
};
|
||||
|
||||
// Carga predictiva al tipear o escanear DNI
|
||||
const lookupPerson = useCallback(async (doc: string) => {
|
||||
const clean = doc.trim();
|
||||
if (clean.length < 4) return;
|
||||
try {
|
||||
const details = await accessApi.getPersonDetails(clean);
|
||||
if (details) {
|
||||
setAssociatedPatentes(details.patentes_asociadas || []);
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
apellido: details.apellido || prev.apellido,
|
||||
nombre: details.nombre || prev.nombre,
|
||||
sexo: details.sexo || prev.sexo,
|
||||
patente: prev.patente || details.patente_sugerida || '',
|
||||
seguro_empresa: details.seguro_empresa || prev.seguro_empresa,
|
||||
seguro_poliza: details.seguro_poliza || prev.seguro_poliza,
|
||||
seguro_desde: details.seguro_desde || prev.seguro_desde,
|
||||
seguro_hasta: details.seguro_hasta || prev.seguro_hasta,
|
||||
art_empresa: details.art_empresa || prev.art_empresa,
|
||||
art_poliza: details.art_poliza || prev.art_poliza,
|
||||
art_desde: details.art_desde || prev.art_desde,
|
||||
art_hasta: details.art_hasta || prev.art_hasta,
|
||||
licencia_nro: details.licencia_nro || prev.licencia_nro,
|
||||
licencia_entidad: details.licencia_entidad || prev.licencia_entidad,
|
||||
licencia_hasta: details.licencia_hasta || prev.licencia_hasta,
|
||||
observaciones: details.observaciones || prev.observaciones,
|
||||
}));
|
||||
}
|
||||
} catch {
|
||||
// Persona nueva sin registro previo
|
||||
}
|
||||
}, []);
|
||||
|
||||
// Carga predictiva al tipear o seleccionar patente
|
||||
const lookupVehicle = useCallback(async (pat: string) => {
|
||||
const clean = pat.replace(/[\s-]/g, '').toUpperCase();
|
||||
if (clean.length < 6) return;
|
||||
try {
|
||||
const v = await accessApi.getVehicleDetails(clean);
|
||||
if (v) {
|
||||
setForm((prev) => ({
|
||||
...prev,
|
||||
seguro_empresa: v.aseguradora || prev.seguro_empresa,
|
||||
seguro_poliza: v.poliza_nro || prev.seguro_poliza,
|
||||
seguro_desde: v.vigencia_desde || prev.seguro_desde,
|
||||
seguro_hasta: v.vigencia_hasta || prev.seguro_hasta,
|
||||
documento: prev.documento || v.documento || '',
|
||||
apellido: prev.apellido || v.apellido || '',
|
||||
nombre: prev.nombre || v.nombre || '',
|
||||
}));
|
||||
}
|
||||
} catch {
|
||||
// Auto nuevo
|
||||
}
|
||||
}, []);
|
||||
|
||||
const setQuickExpiry = (field: 'seguro_hasta' | 'art_hasta' | 'licencia_hasta', months: number) => {
|
||||
const d = new Date();
|
||||
d.setMonth(d.getMonth() + months);
|
||||
const yyyy = d.getFullYear();
|
||||
const mm = String(d.getMonth() + 1).padStart(2, '0');
|
||||
const dd = String(d.getDate()).padStart(2, '0');
|
||||
setForm((prev) => ({ ...prev, [field]: `${yyyy}-${mm}-${dd}` }));
|
||||
};
|
||||
|
||||
// Callback al escanear DNI con cámara
|
||||
const handleDniScanned = (data: DNIParsedResult) => {
|
||||
setForm((prev) => ({
|
||||
@@ -217,17 +328,71 @@ export const ControlPostView: React.FC = () => {
|
||||
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
|
||||
const handleRegisterEntry = async (e: React.FormEvent) => {
|
||||
e.preventDefault();
|
||||
if (!form.documento.trim()) {
|
||||
setActionError('El número de documento es obligatorio.');
|
||||
// Envío del formulario de Ingreso con Validación Estricta
|
||||
const handleRegisterEntry = async (e?: React.FormEvent, forceRestricted = false) => {
|
||||
if (e) e.preventDefault();
|
||||
|
||||
// 1. Validar Documento
|
||||
const docClean = form.documento.trim();
|
||||
if (!docClean || docClean.length < 4) {
|
||||
setActionError('El número de documento es obligatorio (mínimo 4 caracteres).');
|
||||
return;
|
||||
}
|
||||
|
||||
// 2. Validar Nombre
|
||||
if (!form.nombre.trim()) {
|
||||
setActionError('El nombre de la persona es obligatorio.');
|
||||
return;
|
||||
}
|
||||
|
||||
// 3. Validar Lote de Destino
|
||||
if (!form.lote_id && !form.lote_codigo.trim()) {
|
||||
setActionError('Debe seleccionar el lote de destino (obligatorio).');
|
||||
return;
|
||||
}
|
||||
|
||||
// 4. Validar Restricción de Lote (Categoría 26)
|
||||
if (lotPermission?.estado === 'Restringido' && !forceRestricted && !form.forzar_ingreso_lote_restringido) {
|
||||
setConfirmRestrictedModal(true);
|
||||
return;
|
||||
}
|
||||
|
||||
// 5. Validar Conductor (Patente y Seguro)
|
||||
if (form.tipo_ingreso === 'CONDUCTOR') {
|
||||
const patClean = form.patente.trim().toUpperCase();
|
||||
if (!patClean) {
|
||||
setActionError('Falta la Patente del vehículo (obligatoria para conductores).');
|
||||
return;
|
||||
}
|
||||
|
||||
const segStat = getPolicyStatus(form.seguro_hasta);
|
||||
if (segStat.status === 'missing' || segStat.status === 'invalid' || segStat.status === 'expired') {
|
||||
setActionError(
|
||||
`Acceso Bloqueado: Seguro Automotor Inválido (${segStat.label}). Por políticas de seguridad, no se autoriza el ingreso de vehículos sin cobertura de seguro vigente.`
|
||||
);
|
||||
setShowPoliciesSection(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// 6. Validar ART para Trabajadores / Servicios / Proveedores
|
||||
const esTrabajador = ['TRABAJADOR', 'SERVICIO', 'PROVEEDOR', 'OBRA'].includes(form.motivo);
|
||||
if (esTrabajador && form.art_hasta) {
|
||||
const artStat = getPolicyStatus(form.art_hasta);
|
||||
if (artStat.status === 'expired' || artStat.status === 'invalid') {
|
||||
setActionError(
|
||||
`Acceso Bloqueado: Cobertura ART / Accidentes Personales ${artStat.label}. Para personal de trabajo se exige póliza vigente.`
|
||||
);
|
||||
setShowPoliciesSection(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!selectedEntryModuleId) {
|
||||
setActionError('Debe seleccionar un módulo de entrada.');
|
||||
return;
|
||||
@@ -241,34 +406,52 @@ export const ControlPostView: React.FC = () => {
|
||||
const payload: EntryFormData = {
|
||||
...form,
|
||||
modulo_ingreso_id: selectedEntryModuleId,
|
||||
documento: form.documento.trim(),
|
||||
documento: docClean,
|
||||
apellido: form.apellido.trim().toUpperCase(),
|
||||
nombre: form.nombre.trim().toUpperCase(),
|
||||
patente: form.patente.trim().toUpperCase() || '',
|
||||
patente: form.tipo_ingreso === 'CONDUCTOR' ? form.patente.trim().toUpperCase() : '',
|
||||
forzar_ingreso_lote_restringido: forceRestricted || form.forzar_ingreso_lote_restringido,
|
||||
};
|
||||
|
||||
const res = await accessApi.registerEntry(payload);
|
||||
setActionSuccess(`Ingreso registrado con éxito (Ticket #${res.ticket_id}) - ${res.barrier_opened ? 'Barrera Abierta' : ''}`);
|
||||
setActionSuccess(`✓ Ingreso registrado con éxito (Ticket #${res.ticket_id}) - ${res.barrier_opened ? 'Barrera Abierta' : ''}`);
|
||||
setTimeout(() => setActionSuccess(null), 5000);
|
||||
|
||||
// Limpiar formulario para el siguiente vehículo
|
||||
// Limpiar formulario para el siguiente acceso
|
||||
setForm({
|
||||
modulo_ingreso_id: selectedEntryModuleId,
|
||||
documento: '',
|
||||
apellido: '',
|
||||
nombre: '',
|
||||
sexo: 'M',
|
||||
tipo_ingreso: 'CONDUCTOR',
|
||||
patente: '',
|
||||
lote_id: null,
|
||||
lote_codigo: '',
|
||||
motivo: 'VISITA',
|
||||
entidad: '',
|
||||
cantidad_ocupantes: 1,
|
||||
cantidad_menores: 0,
|
||||
cacheo_salida: false,
|
||||
abrir_barrera: true,
|
||||
integrantes: [],
|
||||
seguro_empresa: '',
|
||||
seguro_poliza: '',
|
||||
seguro_desde: '',
|
||||
seguro_hasta: '',
|
||||
art_empresa: '',
|
||||
art_poliza: '',
|
||||
art_desde: '',
|
||||
art_hasta: '',
|
||||
licencia_nro: '',
|
||||
licencia_entidad: '',
|
||||
licencia_hasta: '',
|
||||
observaciones: '',
|
||||
forzar_ingreso_lote_restringido: false,
|
||||
});
|
||||
setAssociatedPatentes([]);
|
||||
setLotPermission(null);
|
||||
setConfirmRestrictedModal(false);
|
||||
|
||||
loadActiveTickets();
|
||||
} catch (err: any) {
|
||||
@@ -278,6 +461,7 @@ export const ControlPostView: React.FC = () => {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
// Abrir diálogo interactivo de verificación de salida
|
||||
const handleOpenExitModal = (ticket: ActiveTicket) => {
|
||||
if (!selectedExitModuleId) {
|
||||
@@ -615,7 +799,53 @@ export const ControlPostView: React.FC = () => {
|
||||
ESCANEAR DNI CON CÁMARA
|
||||
</button>
|
||||
|
||||
<form onSubmit={handleRegisterEntry} style={{ display: 'flex', flexDirection: 'column', gap: '0.85rem' }}>
|
||||
<form onSubmit={(e) => handleRegisterEntry(e)} style={{ display: 'flex', flexDirection: 'column', gap: '0.85rem' }}>
|
||||
{/* Selector de Modo: Conductor (Vehicular) vs Peatón (Tablet Friendly 48px) */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '0.5rem' }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setForm((prev) => ({ ...prev, tipo_ingreso: 'CONDUCTOR' }))}
|
||||
style={{
|
||||
minHeight: '48px',
|
||||
borderRadius: '8px',
|
||||
border: form.tipo_ingreso === 'CONDUCTOR' ? '2px solid var(--accent-primary)' : '1px solid var(--border-subtle)',
|
||||
backgroundColor: form.tipo_ingreso === 'CONDUCTOR' ? 'var(--accent-primary)' : 'var(--bg-card)',
|
||||
color: form.tipo_ingreso === 'CONDUCTOR' ? '#fff' : 'var(--text-primary)',
|
||||
fontWeight: 700,
|
||||
fontSize: '0.95rem',
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: '0.45rem',
|
||||
transition: 'all 0.15s ease',
|
||||
}}
|
||||
>
|
||||
<span>🚗</span> Conductor
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setForm((prev) => ({ ...prev, tipo_ingreso: 'PEATON' }))}
|
||||
style={{
|
||||
minHeight: '48px',
|
||||
borderRadius: '8px',
|
||||
border: form.tipo_ingreso === 'PEATON' ? '2px solid var(--accent-primary)' : '1px solid var(--border-subtle)',
|
||||
backgroundColor: form.tipo_ingreso === 'PEATON' ? 'var(--accent-primary)' : 'var(--bg-card)',
|
||||
color: form.tipo_ingreso === 'PEATON' ? '#fff' : 'var(--text-primary)',
|
||||
fontWeight: 700,
|
||||
fontSize: '0.95rem',
|
||||
cursor: 'pointer',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'center',
|
||||
gap: '0.45rem',
|
||||
transition: 'all 0.15s ease',
|
||||
}}
|
||||
>
|
||||
<span>🚶</span> Peatón
|
||||
</button>
|
||||
</div>
|
||||
|
||||
{/* Selector de Módulo de Entrada */}
|
||||
{config && config.entry_modules.length > 0 && (
|
||||
<div>
|
||||
@@ -645,17 +875,45 @@ export const ControlPostView: React.FC = () => {
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 90px', gap: '0.5rem' }}>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.75rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
DOCUMENTO / DNI:
|
||||
DOCUMENTO / DNI <span style={{ color: '#f44336' }}>*</span>:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.documento}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, documento: e.target.value }))}
|
||||
placeholder="Ej: 30123456"
|
||||
required
|
||||
style={{ width: '100%', marginTop: '0.25rem' }}
|
||||
/>
|
||||
<div style={{ position: 'relative', marginTop: '0.25rem' }}>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.documento}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, documento: e.target.value }))}
|
||||
onBlur={() => lookupPerson(form.documento)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
lookupPerson(form.documento);
|
||||
}
|
||||
}}
|
||||
placeholder="Ej: 30123456"
|
||||
required
|
||||
style={{ width: '100%', paddingRight: '2rem' }}
|
||||
/>
|
||||
{form.documento && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setForm((prev) => ({ ...prev, documento: '' }))}
|
||||
style={{
|
||||
position: 'absolute',
|
||||
right: '8px',
|
||||
top: '50%',
|
||||
transform: 'translateY(-50%)',
|
||||
background: 'none',
|
||||
border: 'none',
|
||||
color: 'var(--text-muted)',
|
||||
cursor: 'pointer',
|
||||
fontSize: '1rem',
|
||||
}}
|
||||
>
|
||||
✕
|
||||
</button>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.75rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
@@ -691,7 +949,7 @@ export const ControlPostView: React.FC = () => {
|
||||
</div>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.75rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
NOMBRE:
|
||||
NOMBRE <span style={{ color: '#f44336' }}>*</span>:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
@@ -699,30 +957,70 @@ export const ControlPostView: React.FC = () => {
|
||||
value={form.nombre}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, nombre: e.target.value }))}
|
||||
placeholder="Ej: JUAN"
|
||||
required
|
||||
style={{ width: '100%', marginTop: '0.25rem', textTransform: 'uppercase' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Patente y Lote de Destino con Autocomplete */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '0.5rem' }}>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.75rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
PATENTE VEHÍCULO:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.patente}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, patente: e.target.value.toUpperCase() }))}
|
||||
placeholder="Ej: AB123CD"
|
||||
style={{ width: '100%', marginTop: '0.25rem', textTransform: 'uppercase' }}
|
||||
/>
|
||||
</div>
|
||||
{/* Patente (Solo si Conductor) y Lote de Destino con Autocomplete */}
|
||||
<div style={{ display: 'grid', gridTemplateColumns: form.tipo_ingreso === 'CONDUCTOR' ? '1fr 1fr' : '1fr', gap: '0.5rem' }}>
|
||||
{form.tipo_ingreso === 'CONDUCTOR' && (
|
||||
<div>
|
||||
<label style={{ fontSize: '0.75rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
PATENTE VEHÍCULO <span style={{ color: '#f44336' }}>*</span>:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.patente}
|
||||
onChange={(e) => {
|
||||
const p = e.target.value.toUpperCase();
|
||||
setForm((prev) => ({ ...prev, patente: p }));
|
||||
}}
|
||||
onBlur={() => lookupVehicle(form.patente)}
|
||||
onKeyDown={(e) => {
|
||||
if (e.key === 'Enter') {
|
||||
e.preventDefault();
|
||||
lookupVehicle(form.patente);
|
||||
}
|
||||
}}
|
||||
placeholder="Ej: AB123CD"
|
||||
style={{ width: '100%', marginTop: '0.25rem', textTransform: 'uppercase' }}
|
||||
/>
|
||||
{associatedPatentes.length > 0 && (
|
||||
<div style={{ display: 'flex', flexWrap: 'wrap', gap: '0.3rem', marginTop: '0.35rem' }}>
|
||||
<span style={{ fontSize: '0.7rem', color: 'var(--text-secondary)', alignSelf: 'center' }}>Sugeridas:</span>
|
||||
{associatedPatentes.map((p) => (
|
||||
<button
|
||||
type="button"
|
||||
key={p}
|
||||
onClick={() => {
|
||||
setForm((prev) => ({ ...prev, patente: p }));
|
||||
lookupVehicle(p);
|
||||
}}
|
||||
style={{
|
||||
padding: '0.2rem 0.5rem',
|
||||
borderRadius: '4px',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
backgroundColor: form.patente === p ? 'var(--accent-primary)' : 'var(--bg-app)',
|
||||
color: form.patente === p ? '#fff' : 'var(--text-primary)',
|
||||
fontSize: '0.75rem',
|
||||
fontWeight: 700,
|
||||
cursor: 'pointer',
|
||||
}}
|
||||
>
|
||||
{p}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div style={{ position: 'relative' }}>
|
||||
<label style={{ fontSize: '0.75rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
LOTE / DESTINO:
|
||||
LOTE / DESTINO <span style={{ color: '#f44336' }}>*</span>:
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
@@ -733,6 +1031,7 @@ export const ControlPostView: React.FC = () => {
|
||||
if (lotSuggestions.length > 0) setShowLotSuggestions(true);
|
||||
}}
|
||||
placeholder="Ej: 142"
|
||||
required
|
||||
style={{ width: '100%', marginTop: '0.25rem' }}
|
||||
/>
|
||||
{/* Desplegable de sugerencias de Lotes */}
|
||||
@@ -902,11 +1201,292 @@ export const ControlPostView: React.FC = () => {
|
||||
</div>
|
||||
) : (
|
||||
<span style={{ fontSize: '0.75rem', color: 'var(--text-secondary)' }}>
|
||||
Solo conductor registrado. Haga clic en "+ Cargar Acompañantes" para registrar más ocupantes.
|
||||
{form.tipo_ingreso === 'CONDUCTOR' ? 'Solo conductor.' : 'Solo peatón.'} Presione "+ Cargar Acompañantes" para registrar más ocupantes.
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* ===================================================================
|
||||
SECCIÓN DE DOCUMENTACIÓN Y PÓLIZAS (Seguro / ART / Licencia)
|
||||
=================================================================== */}
|
||||
<div
|
||||
style={{
|
||||
backgroundColor: 'var(--bg-card)',
|
||||
borderRadius: '8px',
|
||||
border: '1px solid var(--border-subtle)',
|
||||
overflow: 'hidden',
|
||||
}}
|
||||
>
|
||||
{/* Cabecera del Accordion con Badges de Estado */}
|
||||
<div
|
||||
onClick={() => setShowPoliciesSection((prev) => !prev)}
|
||||
style={{
|
||||
padding: '0.65rem 0.85rem',
|
||||
display: 'flex',
|
||||
alignItems: 'center',
|
||||
justifyContent: 'space-between',
|
||||
cursor: 'pointer',
|
||||
backgroundColor: 'var(--bg-surface)',
|
||||
borderBottom: showPoliciesSection ? '1px solid var(--border-subtle)' : 'none',
|
||||
userSelect: 'none',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.45rem', flexWrap: 'wrap' }}>
|
||||
<span style={{ fontSize: '0.95rem' }}>🛡️</span>
|
||||
<span style={{ fontSize: '0.85rem', fontWeight: 700, color: 'var(--text-primary)' }}>
|
||||
Pólizas y Coberturas
|
||||
</span>
|
||||
{form.tipo_ingreso === 'CONDUCTOR' && (
|
||||
<span
|
||||
style={{
|
||||
fontSize: '0.7rem',
|
||||
padding: '0.12rem 0.4rem',
|
||||
borderRadius: '4px',
|
||||
backgroundColor: getPolicyStatus(form.seguro_hasta).bg,
|
||||
color: getPolicyStatus(form.seguro_hasta).color,
|
||||
border: `1px solid ${getPolicyStatus(form.seguro_hasta).border}`,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
Seguro: {getPolicyStatus(form.seguro_hasta).label}
|
||||
</span>
|
||||
)}
|
||||
{['TRABAJADOR', 'SERVICIO', 'PROVEEDOR', 'OBRA'].includes(form.motivo) && (
|
||||
<span
|
||||
style={{
|
||||
fontSize: '0.7rem',
|
||||
padding: '0.12rem 0.4rem',
|
||||
borderRadius: '4px',
|
||||
backgroundColor: getPolicyStatus(form.art_hasta).bg,
|
||||
color: getPolicyStatus(form.art_hasta).color,
|
||||
border: `1px solid ${getPolicyStatus(form.art_hasta).border}`,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
ART: {getPolicyStatus(form.art_hasta).label}
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<span style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}>
|
||||
{showPoliciesSection ? '▲' : '▼'}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
{showPoliciesSection && (
|
||||
<div style={{ padding: '0.75rem', display: 'flex', flexDirection: 'column', gap: '0.75rem' }}>
|
||||
{/* 1. Seguro Automotor (Solo Conductor) */}
|
||||
{form.tipo_ingreso === 'CONDUCTOR' && (
|
||||
<div style={{ padding: '0.6rem', borderRadius: '6px', backgroundColor: 'var(--bg-app)', border: '1px solid var(--border-subtle)' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '0.4rem' }}>
|
||||
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-primary)' }}>
|
||||
🚗 Seguro Automotor <span style={{ color: '#f44336' }}>*</span>
|
||||
</span>
|
||||
<span
|
||||
style={{
|
||||
fontSize: '0.7rem',
|
||||
padding: '0.12rem 0.45rem',
|
||||
borderRadius: '4px',
|
||||
backgroundColor: getPolicyStatus(form.seguro_hasta).bg,
|
||||
color: getPolicyStatus(form.seguro_hasta).color,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{getPolicyStatus(form.seguro_hasta).label}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '0.4rem', marginBottom: '0.4rem' }}>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Aseguradora:</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.seguro_empresa || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, seguro_empresa: e.target.value }))}
|
||||
placeholder="Ej: La Segunda / Zurich"
|
||||
style={{ width: '100%', minHeight: '38px', fontSize: '0.85rem' }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Nro. Póliza:</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.seguro_poliza || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, seguro_poliza: e.target.value }))}
|
||||
placeholder="Ej: POL-998822"
|
||||
style={{ width: '100%', minHeight: '38px', fontSize: '0.85rem' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Vencimiento Cobertura:</label>
|
||||
<div style={{ display: 'flex', gap: '0.25rem' }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setQuickExpiry('seguro_hasta', 1)}
|
||||
style={{ fontSize: '0.68rem', padding: '0.1rem 0.4rem', borderRadius: '4px', border: '1px solid var(--border-subtle)', background: 'var(--bg-card)', cursor: 'pointer' }}
|
||||
>
|
||||
+1M
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setQuickExpiry('seguro_hasta', 6)}
|
||||
style={{ fontSize: '0.68rem', padding: '0.1rem 0.4rem', borderRadius: '4px', border: '1px solid var(--border-subtle)', background: 'var(--bg-card)', cursor: 'pointer' }}
|
||||
>
|
||||
+6M
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setQuickExpiry('seguro_hasta', 12)}
|
||||
style={{ fontSize: '0.68rem', padding: '0.1rem 0.4rem', borderRadius: '4px', border: '1px solid var(--border-subtle)', background: 'var(--bg-card)', cursor: 'pointer' }}
|
||||
>
|
||||
+1A
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
type="date"
|
||||
className="input-touch"
|
||||
value={form.seguro_hasta || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, seguro_hasta: e.target.value }))}
|
||||
style={{
|
||||
width: '100%',
|
||||
minHeight: '40px',
|
||||
marginTop: '0.2rem',
|
||||
border: getPolicyStatus(form.seguro_hasta).status === 'expired' ? '2px solid #f44336' : undefined,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{/* 2. Póliza ART / Accidentes Personales */}
|
||||
<div style={{ padding: '0.6rem', borderRadius: '6px', backgroundColor: 'var(--bg-app)', border: '1px solid var(--border-subtle)' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between', marginBottom: '0.4rem' }}>
|
||||
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-primary)' }}>
|
||||
👷 ART / Accidentes Personales
|
||||
</span>
|
||||
<span
|
||||
style={{
|
||||
fontSize: '0.7rem',
|
||||
padding: '0.12rem 0.45rem',
|
||||
borderRadius: '4px',
|
||||
backgroundColor: getPolicyStatus(form.art_hasta).bg,
|
||||
color: getPolicyStatus(form.art_hasta).color,
|
||||
fontWeight: 700,
|
||||
}}
|
||||
>
|
||||
{getPolicyStatus(form.art_hasta).label}
|
||||
</span>
|
||||
</div>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '0.4rem', marginBottom: '0.4rem' }}>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Compañía ART:</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.art_empresa || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, art_empresa: e.target.value }))}
|
||||
placeholder="Ej: Prevención ART"
|
||||
style={{ width: '100%', minHeight: '38px', fontSize: '0.85rem' }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Nro. Póliza ART:</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.art_poliza || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, art_poliza: e.target.value }))}
|
||||
placeholder="Ej: ART-5544"
|
||||
style={{ width: '100%', minHeight: '38px', fontSize: '0.85rem' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style={{ display: 'flex', alignItems: 'center', justifyContent: 'space-between' }}>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Vencimiento Cobertura ART:</label>
|
||||
<div style={{ display: 'flex', gap: '0.25rem' }}>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setQuickExpiry('art_hasta', 1)}
|
||||
style={{ fontSize: '0.68rem', padding: '0.1rem 0.4rem', borderRadius: '4px', border: '1px solid var(--border-subtle)', background: 'var(--bg-card)', cursor: 'pointer' }}
|
||||
>
|
||||
+1M
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
onClick={() => setQuickExpiry('art_hasta', 6)}
|
||||
style={{ fontSize: '0.68rem', padding: '0.1rem 0.4rem', borderRadius: '4px', border: '1px solid var(--border-subtle)', background: 'var(--bg-card)', cursor: 'pointer' }}
|
||||
>
|
||||
+6M
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<input
|
||||
type="date"
|
||||
className="input-touch"
|
||||
value={form.art_hasta || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, art_hasta: e.target.value }))}
|
||||
style={{
|
||||
width: '100%',
|
||||
minHeight: '40px',
|
||||
marginTop: '0.2rem',
|
||||
border: getPolicyStatus(form.art_hasta).status === 'expired' ? '2px solid #f44336' : undefined,
|
||||
}}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 3. Licencia de Conducir (Opcional) */}
|
||||
<div style={{ padding: '0.6rem', borderRadius: '6px', backgroundColor: 'var(--bg-app)', border: '1px solid var(--border-subtle)' }}>
|
||||
<span style={{ fontSize: '0.8rem', fontWeight: 700, color: 'var(--text-primary)', display: 'block', marginBottom: '0.4rem' }}>
|
||||
🪪 Licencia de Conducir
|
||||
</span>
|
||||
<div style={{ display: 'grid', gridTemplateColumns: '1fr 1fr', gap: '0.4rem' }}>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Nro. Registro:</label>
|
||||
<input
|
||||
type="text"
|
||||
className="input-touch"
|
||||
value={form.licencia_nro || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, licencia_nro: e.target.value }))}
|
||||
placeholder="Ej: B-30123456"
|
||||
style={{ width: '100%', minHeight: '38px', fontSize: '0.85rem' }}
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label style={{ fontSize: '0.7rem', color: 'var(--text-secondary)' }}>Vigencia Hasta:</label>
|
||||
<input
|
||||
type="date"
|
||||
className="input-touch"
|
||||
value={form.licencia_hasta || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, licencia_hasta: e.target.value }))}
|
||||
style={{ width: '100%', minHeight: '38px' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 4. Observaciones */}
|
||||
<div>
|
||||
<label style={{ fontSize: '0.7rem', fontWeight: 600, color: 'var(--text-secondary)' }}>
|
||||
OBSERVACIONES Y NOTAS:
|
||||
</label>
|
||||
<textarea
|
||||
className="input-touch"
|
||||
rows={2}
|
||||
value={form.observaciones || ''}
|
||||
onChange={(e) => setForm((prev) => ({ ...prev, observaciones: e.target.value }))}
|
||||
placeholder="Notas de guardia, autorizaciones especiales..."
|
||||
style={{ width: '100%', marginTop: '0.2rem', resize: 'vertical' }}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
{/* Switch Abrir Barrera */}
|
||||
<div
|
||||
style={{
|
||||
@@ -1350,6 +1930,81 @@ export const ControlPostView: React.FC = () => {
|
||||
loadActiveTickets();
|
||||
}}
|
||||
/>
|
||||
|
||||
{/* Modal de Confirmación para Lote con Restricción (Cat 26) */}
|
||||
{confirmRestrictedModal && (
|
||||
<div
|
||||
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
|
||||
style={{
|
||||
backgroundColor: 'var(--bg-card)',
|
||||
borderRadius: '12px',
|
||||
padding: '1.5rem',
|
||||
maxWidth: '480px',
|
||||
width: '100%',
|
||||
boxShadow: '0 10px 25px rgba(0,0,0,0.5)',
|
||||
border: '2px solid #f44336',
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: '0.75rem', marginBottom: '1rem' }}>
|
||||
<span style={{ fontSize: '2rem' }}>⛔</span>
|
||||
<div>
|
||||
<h3 style={{ margin: 0, fontSize: '1.2rem', color: '#f44336' }}>
|
||||
Lote con Restricción Activa
|
||||
</h3>
|
||||
<span style={{ fontSize: '0.85rem', color: 'var(--text-secondary)' }}>
|
||||
Categoría 26 - {lotPermission?.detalle}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
<p style={{ fontSize: '0.95rem', color: 'var(--text-primary)', lineHeight: 1.4, margin: '0 0 1.25rem 0' }}>
|
||||
El lote <strong>{form.lote_codigo}</strong> posee una restricción registrada en el consorcio.
|
||||
¿Desea forzar el ingreso bajo responsabilidad del operador de guardia?
|
||||
</p>
|
||||
<div style={{ display: 'flex', gap: '0.75rem', justifyContent: 'flex-end' }}>
|
||||
<button
|
||||
type="button"
|
||||
className="btn btn-secondary"
|
||||
onClick={() => setConfirmRestrictedModal(false)}
|
||||
style={{ minHeight: '44px', padding: '0 1.25rem', fontWeight: 600 }}
|
||||
>
|
||||
Cancelar
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
className="btn"
|
||||
onClick={() => {
|
||||
setConfirmRestrictedModal(false);
|
||||
handleRegisterEntry(undefined, true);
|
||||
}}
|
||||
style={{
|
||||
minHeight: '44px',
|
||||
padding: '0 1.25rem',
|
||||
fontWeight: 700,
|
||||
backgroundColor: '#f44336',
|
||||
color: '#fff',
|
||||
}}
|
||||
>
|
||||
Forzar Ingreso Autorizado
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user