Se corrigio el sistema de modal de paises

This commit is contained in:
2026-01-22 13:06:08 -06:00
parent 5a254fb2b1
commit 4fda7b28c7
5 changed files with 156 additions and 97 deletions

View File

@@ -5,34 +5,34 @@
import { api } from '$lib/api';
export interface Country {
m3_key: string;
mex_key: string;
ame_key: string;
description_es: string;
description_en: string;
m3_key: string;
mex_key: string;
ame_key: string;
description_es: string;
description_en: string;
}
export interface CountryListResponse {
items: Country[];
total: number;
page: number;
page_size: number;
items: Country[];
total: number;
page: number;
page_size: number;
}
export interface CreateCountryData {
m3_key: string;
mex_key: string;
ame_key: string;
description_es: string;
description_en: string;
m3_key: string;
mex_key: string;
ame_key: string;
description_es: string;
description_en: string;
}
export interface UpdateCountryData {
m3_key?: string;
mex_key?: string;
ame_key?: string;
description_es?: string;
description_en?: string;
m3_key?: string;
mex_key?: string;
ame_key?: string;
description_es?: string;
description_en?: string;
}
/**
@@ -43,18 +43,21 @@ export const countriesApi = {
* Lista todos los países con paginación
* @param page - Número de página (por defecto 1)
* @param pageSize - Tamaño de página (por defecto 50)
* @param search - Término de búsqueda (opcional)
*/
list: (page = 1, pageSize = 50) =>
api.get<CountryListResponse>(
// CORREGIDO: Añadido '/' antes del '?'
`/v1/public/refrence_data/countries/?page=${page}&page_size=${pageSize}`
),
list: (page = 1, pageSize = 50, search?: string) => {
let url = `/v1/public/refrence_data/countries/?page=${page}&page_size=${pageSize}`;
if (search) {
url += `&search=${encodeURIComponent(search)}`;
}
return api.get<CountryListResponse>(url);
},
/**
* Obtiene un país por su clave M3
* @param m3_key - Clave M3 del país
*/
get: (m3_key: string) =>
get: (m3_key: string) =>
// CORREGIDO: Añadido '/' al final
api.get<Country>(`/v1/public/refrence_data/countries/${m3_key}/`),
@@ -79,7 +82,7 @@ export const countriesApi = {
* Elimina un país
* @param m3_key - Clave M3 del país a eliminar
*/
delete: (m3_key: string) =>
delete: (m3_key: string) =>
// CORREGIDO: Añadido '/' después de la clave
api.delete(`/v1/public/refrence_data/countries/${m3_key}/`)
};