From 5c4372df8c11ad0c5e19151227a89d852082fbbb Mon Sep 17 00:00:00 2001 From: KevinMrkz3221 Date: Sat, 6 Dec 2025 19:45:36 -0600 Subject: [PATCH] catalogos --- .../src/lib/api/dashboard/public/countries.ts | 95 +++++++++++++++++++ .../src/lib/components/sidebar/modules.ts | 2 +- 2 files changed, 96 insertions(+), 1 deletion(-) create mode 100644 frontend/src/lib/api/dashboard/public/countries.ts diff --git a/frontend/src/lib/api/dashboard/public/countries.ts b/frontend/src/lib/api/dashboard/public/countries.ts new file mode 100644 index 00000000..df2c61ea --- /dev/null +++ b/frontend/src/lib/api/dashboard/public/countries.ts @@ -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; +} diff --git a/frontend/src/lib/components/sidebar/modules.ts b/frontend/src/lib/components/sidebar/modules.ts index e5806eeb..7beadf0b 100644 --- a/frontend/src/lib/components/sidebar/modules.ts +++ b/frontend/src/lib/components/sidebar/modules.ts @@ -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"](),