catalogos

This commit is contained in:
KevinMrkz3221
2025-12-06 19:45:36 -06:00
parent 64b6f3e5c9
commit 5c4372df8c
2 changed files with 96 additions and 1 deletions

View File

@@ -0,0 +1,95 @@
/**
* API client for Countries operations
*/
import { api } from '$lib/api';
export interface Country {
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;
}
export interface CountryCreateRequest {
m3_key: string;
mex_key: string;
ame_key: string;
description_es: string;
description_en: string;
}
export interface CountryUpdateRequest {
m3_key: string;
mex_key: string;
ame_key: string;
description_es: string;
description_en: string;
}
/**
* Get all countries with pagination
*/
export async function getCountries(
filters?: {
page?: number;
page_size?: number;
}
): Promise<{ data: CountryListResponse; status: number }> {
const params = new URLSearchParams();
if (filters?.page) params.append('page', filters.page.toString());
if (filters?.page_size) params.append('page_size', filters.page_size.toString());
const response = await api.get(`/v1/public/refrence_data/countries?${params.toString()}`);
return response;
}
/**
* Get a single country by m3_key
*/
export async function getCountry(
m3_key: string
): Promise<{ data: Country; status: number }> {
const response = await api.get(`/v1/public/refrence_data/countries/${m3_key}`);
return response;
}
/**
* Create a new country
*/
export async function createCountry(
data: CountryCreateRequest
): Promise<{ data: Country; status: number }> {
const response = await api.post(`/v1/public/refrence_data/countries`, data);
return response;
}
/**
* Update an existing country
*/
export async function updateCountry(
m3_key: string,
data: CountryUpdateRequest
): Promise<{ data: Country; status: number }> {
const response = await api.put(`/v1/public/refrence_data/countries/${m3_key}`, data);
return response;
}
/**
* Delete a country
*/
export async function deleteCountry(
m3_key: string
): Promise<{ data: any; status: number }> {
const response = await api.delete(`/v1/public/refrence_data/countries/${m3_key}`);
return response;
}

View File

@@ -195,7 +195,7 @@ export function getSidebarData(): SidebarData {
},
{
title: m["sidebar.general_catalogs.countries"](),
url: "#",
url: "/dashboard/reference_data/countries",
},
{
title: m["sidebar.general_catalogs.ports"](),