diff --git a/frontend/src/lib/api/dashboard/a76/classes.ts b/frontend/src/lib/api/dashboard/a76/classes.ts index e9ba24d3..21b6b160 100644 --- a/frontend/src/lib/api/dashboard/a76/classes.ts +++ b/frontend/src/lib/api/dashboard/a76/classes.ts @@ -1,6 +1,8 @@ import { api } from '$lib/api'; import type { ApiResponse } from '$lib/api'; +// --- INTERFACES --- + export interface A76Class { id: number; tenant_id: number; @@ -16,10 +18,31 @@ export interface A76Class { sub_key: string; physical_review: number; iva_exempt_fraction: string; + is_active?: boolean; // Agregado para el switch del formulario created_at: string; updated_at: string; } +// DTO para crear (match con tu formulario) +export interface A76ClassCreate { + company_id: number; + client_id: number; + class_code: string; + description_es?: string | null; + description_en?: string | null; + material_key?: string | null; + unit_of_measure?: string | null; + fraction?: string | null; + us_fraction?: string | null; + sub_key?: string | null; + physical_review?: number | null; + iva_exempt_fraction?: string | null; + is_active?: boolean; +} + +// DTO para actualizar (Partial del create) +export interface A76ClassUpdate extends Partial {} + export interface A76ClassListResponse { items: A76Class[]; classes?: A76Class[]; @@ -35,18 +58,33 @@ export interface A76ClassListParams { page_size?: number; class_code?: string; description?: string; + q?: string; // Agregado por si usas búsqueda general } +// --- API OBJECT --- + export const classesApi = { list: (params: A76ClassListParams): Promise> => { const query = new URLSearchParams(); Object.entries(params).forEach(([key, value]) => { - if (value) query.append(key, value.toString()); + if (value !== undefined && value !== null) query.append(key, value.toString()); }); return api.get(`/v1/a76/classes/?${query.toString()}`); }, get: (id: number, company_id: number): Promise> => { return api.get(`/v1/a76/classes/${id}?company_id=${company_id}`); + }, + + create: (data: A76ClassCreate, company_id: number): Promise> => { + return api.post(`/v1/a76/classes/?company_id=${company_id}`, data); + }, + + update: (id: number, data: A76ClassUpdate, company_id: number): Promise> => { + return api.put(`/v1/a76/classes/${id}?company_id=${company_id}`, data); + }, + + delete: (id: number, company_id: number): Promise> => { + return api.delete(`/v1/a76/classes/${id}?company_id=${company_id}`); } }; \ No newline at end of file diff --git a/frontend/src/lib/components/dashboard/classes/columns.ts b/frontend/src/lib/components/dashboard/goods/classes/columns.ts similarity index 100% rename from frontend/src/lib/components/dashboard/classes/columns.ts rename to frontend/src/lib/components/dashboard/goods/classes/columns.ts diff --git a/frontend/src/lib/components/dashboard/classes/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/goods/classes/create-edit-dialog.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/classes/create-edit-dialog.svelte rename to frontend/src/lib/components/dashboard/goods/classes/create-edit-dialog.svelte diff --git a/frontend/src/lib/components/dashboard/classes/data-table-actions.svelte b/frontend/src/lib/components/dashboard/goods/classes/data-table-actions.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/classes/data-table-actions.svelte rename to frontend/src/lib/components/dashboard/goods/classes/data-table-actions.svelte diff --git a/frontend/src/lib/components/dashboard/classes/data-table.svelte b/frontend/src/lib/components/dashboard/goods/classes/data-table.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/classes/data-table.svelte rename to frontend/src/lib/components/dashboard/goods/classes/data-table.svelte diff --git a/frontend/src/lib/components/dashboard/parts/client-selector-dialog.svelte b/frontend/src/lib/components/dashboard/goods/modales/client-selector-dialog.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/parts/client-selector-dialog.svelte rename to frontend/src/lib/components/dashboard/goods/modales/client-selector-dialog.svelte diff --git a/frontend/src/lib/components/dashboard/parts/material-type-selector-dialog.svelte b/frontend/src/lib/components/dashboard/goods/modales/material-type-selector-dialog.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/parts/material-type-selector-dialog.svelte rename to frontend/src/lib/components/dashboard/goods/modales/material-type-selector-dialog.svelte diff --git a/frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte b/frontend/src/lib/components/dashboard/goods/modales/unit-measure-dialog.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/parts/unit-measure-dialog.svelte rename to frontend/src/lib/components/dashboard/goods/modales/unit-measure-dialog.svelte diff --git a/frontend/src/lib/components/dashboard/parts/class-selector-dialog.svelte b/frontend/src/lib/components/dashboard/goods/parts/class-selector-dialog.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/parts/class-selector-dialog.svelte rename to frontend/src/lib/components/dashboard/goods/parts/class-selector-dialog.svelte diff --git a/frontend/src/lib/components/dashboard/parts/columns.ts b/frontend/src/lib/components/dashboard/goods/parts/columns.ts similarity index 100% rename from frontend/src/lib/components/dashboard/parts/columns.ts rename to frontend/src/lib/components/dashboard/goods/parts/columns.ts diff --git a/frontend/src/lib/components/dashboard/parts/create-edit-dialog.svelte b/frontend/src/lib/components/dashboard/goods/parts/create-edit-dialog.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/parts/create-edit-dialog.svelte rename to frontend/src/lib/components/dashboard/goods/parts/create-edit-dialog.svelte diff --git a/frontend/src/lib/components/dashboard/parts/data-table-actions.svelte b/frontend/src/lib/components/dashboard/goods/parts/data-table-actions.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/parts/data-table-actions.svelte rename to frontend/src/lib/components/dashboard/goods/parts/data-table-actions.svelte diff --git a/frontend/src/lib/components/dashboard/parts/data-table.svelte b/frontend/src/lib/components/dashboard/goods/parts/data-table.svelte similarity index 100% rename from frontend/src/lib/components/dashboard/parts/data-table.svelte rename to frontend/src/lib/components/dashboard/goods/parts/data-table.svelte diff --git a/frontend/src/routes/dashboard/goods/classes/+page.svelte b/frontend/src/routes/dashboard/goods/classes/+page.svelte index 7669e858..3bec9de7 100644 --- a/frontend/src/routes/dashboard/goods/classes/+page.svelte +++ b/frontend/src/routes/dashboard/goods/classes/+page.svelte @@ -1,8 +1,8 @@
@@ -177,11 +210,12 @@

{title}

+

Gestión de catálogo de clases (Anexo 24).

{#if error} -
+
⚠️ {error}
{/if} @@ -193,93 +227,132 @@
- -
+ +
+
- -

Máximo 8 caracteres.

+
- - + +
+
+ + showClientModal = true} + /> +
+ +
+ {#if selectedClientName} +
+ {selectedClientName} +
+ {/if}
-
- -