import { api } from '$lib/api';

export interface CartaPorte {
	id: number;
	code: string;
	description: string;
	similar_words?: string;
	is_hazardous?: number;
	start_date?: string;
	end_date?: string;
}

export const cartaPorteApi = {
	list: async (page = 1, pageSize = 50, q = '') => {
		const params = new URLSearchParams({
			page: page.toString(),
			page_size: pageSize.toString(),
			q: q
		});
		return api.get<{ items: CartaPorte[]; total: number }>(
			`/v1/public/reference_data/carta-porte/?${params.toString()}`
		);
	},
	get: async (id: number) => {
		return api.get<CartaPorte>(`/v1/public/reference_data/carta-porte/${id}`);
	}
};
