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

export interface SitarTLCS {
    FRACCION: string;
    PAIS: string;
    TASATXT: string;
    TASANUM?: string | null;
    TLC: string;
    NOTA: string | null;
    DOF: string | null;
    OBSERVACION?: string | null;
    NICO?: string;
    SYSID: number;
}

export interface SitarPROSEC {
    FRACCION: string;
    PRODUCTO: string;
    TASA: string;
    SECTOR: string;
    ANEXO: string;
    DOF: string;
    NOTAS: string | null;
    NICO?: string;
    SYSID: number;
}

export interface SitarALADI {
    FRACCION: string;
    ACUERDO: string;
    PAIS: string;
    TASATXT: string;
    TASANUM?: string | null;
    DOF: string;
    NOTAS: string | null;
    NICO?: string;
    SYSID: number;
}

export async function getSitarTLCS(filters: { fraccion: string; nico?: string }): Promise<ApiResponse<SitarTLCS[]>> {
    const queryParams = new URLSearchParams(filters);
    return await api.get(`/v1/sitar/tlcs/?${queryParams.toString()}`);
}

export async function getSitarPROSEC(filters: { fraccion: string; nico?: string }): Promise<ApiResponse<SitarPROSEC[]>> {
    const queryParams = new URLSearchParams(filters);
    return await api.get(`/v1/sitar/prosec/?${queryParams.toString()}`);
}

export async function getSitarALADI(filters: { fraccion: string; nico?: string }): Promise<ApiResponse<SitarALADI[]>> {
    const queryParams = new URLSearchParams(filters);
    return await api.get(`/v1/sitar/aladi2/?${queryParams.toString()}`);
}
