From b011ae32a47063d918992dff12f3c9d0795ea4e1 Mon Sep 17 00:00:00 2001 From: Kevin_Ramirez Date: Wed, 24 Dec 2025 14:55:57 -0600 Subject: [PATCH] Puliendo el proyecto de archivos redunantes --- .../lib/api/dashboard/a76/customs-brokers.ts | 5 +- .../customs-broker-concepts.ts | 68 ++- .../customs_brokers/create-dialog.svelte | 562 +++++++----------- .../customs_broker_concepts/columns.ts | 2 +- .../create-edite-dialoge.svelte | 8 +- .../data-table-actions.svelte | 2 +- .../equivalency/create-edit-dialog.svelte | 137 ----- .../components/ui/checkbox/checkbox.svelte | 28 + .../src/lib/components/ui/checkbox/index.ts | 7 + .../dashboard/customs_brokers/+page.server.ts | 2 +- .../dashboard/customs_brokers/+page.svelte | 2 +- 11 files changed, 282 insertions(+), 541 deletions(-) delete mode 100644 frontend/src/lib/components/dashboard/general_catalogs/equivalency/create-edit-dialog.svelte create mode 100644 frontend/src/lib/components/ui/checkbox/checkbox.svelte create mode 100644 frontend/src/lib/components/ui/checkbox/index.ts diff --git a/frontend/src/lib/api/dashboard/a76/customs-brokers.ts b/frontend/src/lib/api/dashboard/a76/customs-brokers.ts index 17a82200..149b97b5 100644 --- a/frontend/src/lib/api/dashboard/a76/customs-brokers.ts +++ b/frontend/src/lib/api/dashboard/a76/customs-brokers.ts @@ -1,7 +1,4 @@ -/** - * API Client para Agentes Aduanales (Customs Brokers) - * Gestiona las operaciones CRUD para agentes aduanales - */ + import { api } from '$lib/api'; export interface CustomsBroker { diff --git a/frontend/src/lib/api/dashboard/a76/general_catalogs/customs-broker-concepts.ts b/frontend/src/lib/api/dashboard/a76/general_catalogs/customs-broker-concepts.ts index 3e40b598..e9cf0b07 100644 --- a/frontend/src/lib/api/dashboard/a76/general_catalogs/customs-broker-concepts.ts +++ b/frontend/src/lib/api/dashboard/a76/general_catalogs/customs-broker-concepts.ts @@ -3,17 +3,33 @@ import type { ApiResponse } from '$lib/api'; export interface CustomsBrokerConcept { id: number; - broker_key: string; - concept: string; - amount?: number; - priority?: number; + code: string; + description?: string; + description_en?: string; + detailed_description?: string; + priority?: number; + first_total?: boolean; + type?: string; + is_printed?: boolean; + section?: number; + classification?: string; + tenant_id: string; + company_id?: string; + created_at: string; + updated_at?: string; } export interface CustomsBrokerConceptCreate { - broker_key: string; - concept?: string; - amount?: number; + code: string; + description?: string; + description_en?: string; + detailed_description?: string; priority?: number; + first_total?: boolean; + type?: string; + is_printed?: boolean; + section?: number; + classification?: string; } export interface CustomsBrokerConceptUpdate extends Partial {} @@ -26,12 +42,11 @@ export interface CustomsBrokerConceptListResponse { pages: number; } - export async function getCustomsBrokerConcepts( page: number = 1, pageSize: number = 50, - companyId: number, // <-- Nuevo - filters: Record = {} + companyId: number, + filters: Record = {}, ): Promise> { const params = new URLSearchParams({ page: page.toString(), @@ -40,30 +55,21 @@ export async function getCustomsBrokerConcepts( ...filters }); - - const response = await api.get(`/v1/a76/customs-broker-concepts/?${params.toString()}`); - return response.data; + return await api.get(`/v1/a76/customs-broker-concepts?${params.toString()}`); } -export async function createCustomsBrokerConcept( - data: CustomsBrokerConceptCreate, - companyId: number -): Promise { - - const response = await api.post(`/v1/a76/customs-broker-concepts/?company_id=${companyId}`, data); - return response.data; +export async function getCustomsBrokerConcept(id: number, companyId: number): Promise> { + return await api.get(`/v1/a76/customs-broker-concepts/${id}?company_id=${companyId}`); } -export async function updateCustomsBrokerConcept( - id: number, - data: CustomsBrokerConceptUpdate, - companyId: number -): Promise { - - const response = await api.put(`/v1/a76/customs-broker-concepts/${id}/?company_id=${companyId}`, data); - return response.data; +export async function createCustomsBrokerConcept(data: CustomsBrokerConceptCreate, companyId: number): Promise> { + return await api.post(`/v1/a76/customs-broker-concepts?company_id=${companyId}`, data); } -export async function deleteCustomsBrokerConcept(id: number, companyId: number): Promise { - await api.delete(`/v1/a76/customs-broker-concepts/${id}/?company_id=${companyId}`); -} \ No newline at end of file +export async function updateCustomsBrokerConcept(id: number, data: CustomsBrokerConceptUpdate, companyId: number): Promise> { + return await api.put(`/v1/a76/customs-broker-concepts/${id}?company_id=${companyId}`, data); +} + +export async function deleteCustomsBrokerConcept(id: number, companyId: number): Promise> { + return await api.delete(`/v1/a76/customs-broker-concepts/${id}?company_id=${companyId}`); +} diff --git a/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte b/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte index e623e2f2..fd76c8cf 100644 --- a/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte +++ b/frontend/src/lib/components/dashboard/customs_brokers/create-dialog.svelte @@ -1,381 +1,221 @@ - - - - Nuevo Agente Aduanal - - Completa los datos para crear un nuevo agente aduanal. - - + + + + + {mode === "create" ? "Nuevo Agente Aduanal" : "Editar Agente Aduanal"} + + + Ingresa los datos generales del agente. La configuración de VU y Personal se gestiona aparte. + + -
- {#if error} -
- {error} -
- {/if} +
+ +
+

Identificación

+
+
+ + +
+
+ + +
+
+
+
+ + +
+
+ + +
+
+ + +
+
+
- -
-

Información Básica

- -
-
- - -
+ -
- - -
-
+
+

Contacto

+
+
+ + +
+
+ + +
+
+
-
- - -
+ -
-
- - -
+
+

Dirección Fiscal

+ +
+ + +
-
- - -
-
-
+
+
+ + +
+
+ + +
+
+ + +
+
+
+
+ + +
+
+
- -
-

Información de Contacto

- -
-
- - -
+
-
- - -
-
- -
- - -
- -
- - -
-
- - -
-

Dirección

- -
- - -
- -
-
- - -
- -
- - -
- -
- - -
-
- -
- - -
-
- - -
-

Información Fiscal

- -
-
- - -
- -
- - -
-
- -
- - -
-
- - - - - -
-
-
+ + + + +
+
\ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/columns.ts b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/columns.ts index 9de1fbdf..09fd8bf8 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/columns.ts +++ b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/columns.ts @@ -1,4 +1,4 @@ -import type { CustomsBrokerConcept } from '$lib/api/dashboard/a76/general_catalogs/customs_broker_concepts'; +import type { CustomsBrokerConcept } from '$lib/api/dashboard/a76/general_catalogs/customs-broker-concepts'; import type { ColumnDef } from '@tanstack/table-core'; import { renderComponent } from '$lib/components/ui/data-table'; import DataTableActions from './data-table-actions.svelte'; diff --git a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edite-dialoge.svelte b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edite-dialoge.svelte index c2f4cf21..a6ba9c4b 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edite-dialoge.svelte +++ b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/create-edite-dialoge.svelte @@ -47,8 +47,8 @@ formData = { broker_key: '', concept: '', - amount: '', - priority: '' + amount: null, + priority: null }; } }); @@ -69,8 +69,8 @@ const dataToSend = { broker_key: formData.broker_key.trim(), concept: formData.concept.trim(), - amount: formData.amount ? Number(formData.amount) : null, - priority: formData.priority ? Number(formData.priority) : null + amount: formData.amount ? Number(formData.amount) : undefined, + priority: formData.priority ? Number(formData.priority) : undefined }; // 6. Corregida la sintaxis de llamada a la API diff --git a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/data-table-actions.svelte b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/data-table-actions.svelte index 49dd7b58..66dde523 100644 --- a/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/data-table-actions.svelte +++ b/frontend/src/lib/components/dashboard/general_catalogs/customs_broker_concepts/data-table-actions.svelte @@ -1,7 +1,7 @@ - - - - - - {mode === "create" ? "Nueva Equivalencia" : "Editar Equivalencia"} - - - {mode === "create" - ? "Ingresa los datos para registrar una nueva equivalencia." - : "Modifica los datos de la equivalencia existente."} - - - -
-
- -
- -
-
- -
- -
- -
-
- -
- -
-