- Added server-side loading logic for states, transport modes, transport types, and valuation methods with pagination support. - Created Svelte components for displaying and managing states, transport modes, transport types, and valuation methods. - Implemented infinite scroll functionality for loading more data as the user scrolls. - Added error handling and user feedback for API interactions. - Included dialogs for creating and editing entries in each reference data category.
73 lines
1.6 KiB
TypeScript
73 lines
1.6 KiB
TypeScript
/**
|
|
* API Client para Incoterms
|
|
* Gestiona las operaciones CRUD para los términos internacionales de comercio
|
|
*/
|
|
import { api } from '$lib/api';
|
|
|
|
export interface Incoterm {
|
|
code: string;
|
|
description_es: string;
|
|
description_en: string;
|
|
}
|
|
|
|
export interface IncotermListResponse {
|
|
items: Incoterm[];
|
|
total: number;
|
|
page: number;
|
|
page_size: number;
|
|
}
|
|
|
|
export interface CreateIncotermData {
|
|
code: string;
|
|
description_es: string;
|
|
description_en: string;
|
|
}
|
|
|
|
export interface UpdateIncotermData {
|
|
code?: string;
|
|
description_es?: string;
|
|
description_en?: string;
|
|
}
|
|
|
|
/**
|
|
* API para Incoterms
|
|
*/
|
|
export const incotermsApi = {
|
|
/**
|
|
* Lista todos los incoterms con paginación
|
|
* @param page - Número de página (por defecto 1)
|
|
* @param pageSize - Tamaño de página (por defecto 50)
|
|
*/
|
|
list: (page = 1, pageSize = 50) =>
|
|
api.get<IncotermListResponse>(
|
|
`/v1/incoterms?page=${page}&page_size=${pageSize}`
|
|
),
|
|
|
|
/**
|
|
* Obtiene un incoterm por código
|
|
* @param code - Código del incoterm
|
|
*/
|
|
get: (code: string) => api.get<Incoterm>(`/v1/incoterms/${code}`),
|
|
|
|
/**
|
|
* Crea un nuevo incoterm
|
|
* @param data - Datos del incoterm a crear
|
|
*/
|
|
create: (data: CreateIncotermData) =>
|
|
api.post<Incoterm>('/v1/incoterms', data),
|
|
|
|
/**
|
|
* Actualiza un incoterm existente
|
|
* @param code - Código del incoterm a actualizar
|
|
* @param data - Datos a actualizar
|
|
*/
|
|
update: (code: string, data: UpdateIncotermData) =>
|
|
api.put<Incoterm>(`/v1/incoterms/${code}`, data),
|
|
|
|
/**
|
|
* Elimina un incoterm
|
|
* @param code - Código del incoterm a eliminar
|
|
*/
|
|
delete: (code: string) => api.delete(`/v1/incoterms/${code}`)
|
|
};
|