Mejoramiento de los errores en vehiculos

This commit is contained in:
2026-05-13 09:10:25 -05:00
parent 6f2ce605a8
commit 1482af22cb
2 changed files with 28 additions and 4 deletions

View File

@@ -362,7 +362,27 @@ async function fetchApi<T = any>(
"SERVIDOR FTP": "ftp_server",
"USUARIO FTP": "ftp_user",
"CLAVE ACCESO FTP": "ftp_password",
"DIRECTORIO FTP": "ftp_directory"
"DIRECTORIO FTP": "ftp_directory",
// Vehicles
CLAVE: "vehicle_key",
"CLAVE ACE": "ace_vehicle_key", // Fallback for vehicles
"CLAVE TRANSPORTE": "transporter_key",
VIN: "series",
"TIPO TRANSPORTE": "transport_type",
"CODIGO DE ENTIDAD": "entity_code",
TRANSPONDEDOR: "transponder_number",
"NUMERO DOT": "dot_number",
PLACAS: "plate_number",
PRECINTO: "seal",
"EMPRESA ASEGURADORA": "insurance_company_name",
"NUM. ASEGURADORA": "insurance_number",
"MONTO ASEGURADO": "insurance_amount",
"FECHA DE ASEGURADORA": "insurance_date",
// Trailers
"NUMERO TRAILER": "trailer_number",
"TIPO TRAILER": "trailer_type_key",
"CODIGO ENTIDAD": "entity_code",
"CLAVE CONTENEDOR": "container_key"
};
const normalizedErrors = d.errors.map((err) => ({

View File

@@ -196,6 +196,10 @@
throw new Error(tv('vehicle_key_required'));
}
if (!isEdit && !formData.entity_code) {
throw new Error('El Código de Entidad es obligatorio para nuevos vehículos');
}
let response;
if (isEdit && item) {
response = await vehiclesApi.update(item.vehicle_key, formData, companyId);
@@ -204,9 +208,9 @@
}
if (response.error) {
const ve = (response as { validationErrors?: { msg?: string }[] }).validationErrors;
const ve = response.validationErrors;
if (ve?.length) {
throw new Error(ve.map((e) => e.msg).join(' · '));
throw new Error(ve.map((e) => e.message).join(' · '));
}
throw new Error(response.error);
}
@@ -372,7 +376,7 @@
</div>
<div class="grid gap-2">
<Label for="entity_code">{tv('label_entity_code')}</Label>
<Label for="entity_code">{tv('label_entity_code')} <span class="text-destructive">*</span></Label>
<Select.Root type="single" bind:value={formData.entity_code}>
<Select.Trigger class="w-full" id="entity_code">
{ENTITY_OPTS.find((o) => o.value === (formData.entity_code || ''))?.label ??