feat: Implement reference data management for states, transport modes, transport types, and valuation methods
- 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.
This commit is contained in:
72
frontend/src/lib/api/dashboard/refrence_data/sectors.ts
Normal file
72
frontend/src/lib/api/dashboard/refrence_data/sectors.ts
Normal file
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* API Client para Sectors
|
||||
* Gestiona las operaciones CRUD para los sectores
|
||||
*/
|
||||
import { api } from '$lib/api';
|
||||
|
||||
export interface Sector {
|
||||
key: string;
|
||||
description: string;
|
||||
authorized: number;
|
||||
}
|
||||
|
||||
export interface SectorListResponse {
|
||||
items: Sector[];
|
||||
total: number;
|
||||
page: number;
|
||||
page_size: number;
|
||||
}
|
||||
|
||||
export interface CreateSectorData {
|
||||
key: string;
|
||||
description: string;
|
||||
authorized: number;
|
||||
}
|
||||
|
||||
export interface UpdateSectorData {
|
||||
key?: string;
|
||||
description?: string;
|
||||
authorized?: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* API para Sectors
|
||||
*/
|
||||
export const sectorsApi = {
|
||||
/**
|
||||
* Lista todos los sectores 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<SectorListResponse>(
|
||||
`/v1/sectors?page=${page}&page_size=${pageSize}`
|
||||
),
|
||||
|
||||
/**
|
||||
* Obtiene un sector por key
|
||||
* @param key - Clave del sector
|
||||
*/
|
||||
get: (key: string) => api.get<Sector>(`/v1/sectors/${key}`),
|
||||
|
||||
/**
|
||||
* Crea un nuevo sector
|
||||
* @param data - Datos del sector a crear
|
||||
*/
|
||||
create: (data: CreateSectorData) =>
|
||||
api.post<Sector>('/v1/sectors', data),
|
||||
|
||||
/**
|
||||
* Actualiza un sector existente
|
||||
* @param key - Clave del sector a actualizar
|
||||
* @param data - Datos a actualizar
|
||||
*/
|
||||
update: (key: string, data: UpdateSectorData) =>
|
||||
api.put<Sector>(`/v1/sectors/${key}`, data),
|
||||
|
||||
/**
|
||||
* Elimina un sector
|
||||
* @param key - Clave del sector a eliminar
|
||||
*/
|
||||
delete: (key: string) => api.delete(`/v1/sectors/${key}`)
|
||||
};
|
||||
Reference in New Issue
Block a user