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

export interface FDACatalog {
  id: number;
  fda_key: string;
  description: string;
  fda_code?: string;
  requirements?: string;
  manufacturer_number?: string;
  country_of_production?: string;
  storage_status?: string;
  warehouse_code?: string;
  call_atl?: string;
  created_at?: string;
  updated_at?: string;
}

export async function getFDACatalog(
  page: number,
  pageSize: number,
  companyId: number,
  filters: any = {}
): Promise<any> {
  try {
    const queryParams = new URLSearchParams({
      page: page.toString(),
      page_size: pageSize.toString(),
      company_id: companyId.toString()
    });

    if (filters.search) {
      queryParams.append('search', filters.search);
    }

    const response = await api.get(`/v1/a76/fda-catalog/?${queryParams.toString()}`);
    return response;
  } catch (error) {
    console.error('Error fetching FDA catalog:', error);
    throw error;
  }
}
