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

export interface AphisCatalogRecord {
  id?: number;
  // --- Pestaña 1: General ---
  program_code?: string;
  processing_code?: string;
  aphis_type?: string;
  disclaimer?: string;
  electronic_image?: string;
  confidential?: string;
  global_product_id?: string;
  intended_use_code?: string;
  intended_use_description?: string;
  item_type?: string;
  product_code?: string;
  product_code_2?: string;
  product_code_3?: string;
  scientific_genus_name?: string;
  scientific_species_name?: string;
  scientific_sub_species_name?: string;
  common_name_specific?: string;
  common_name_general?: string;
  signed_doc?: string;
  signed_doc_date?: string;
  signed_doc_id?: string;
  invoice_number?: string;
  quantity_1?: string;
  quantity_2?: string;
  quantity_3?: string;
  inspection?: string;
  inspection_date?: string;
  inspection_loc_date?: string;
  inspection_location?: string;
  country_production?: string;
  country_source?: string;

  // --- Pestañas 2-7: Detalles ---
  characteristics?: any[];
  pitems?: any[];
  lpcos?: any[];
  entities?: any[];
  containers?: any[];
  routing?: any[];
}

export const aphisCatalogApi = {
  list: (company_id: number) =>
    api.get<AphisCatalogRecord[]>(`/v1/a24/aphis-catalog/?company_id=${company_id}`),

  create: (data: AphisCatalogRecord, company_id: number) =>
    api.post<AphisCatalogRecord>(`/v1/a24/aphis-catalog/?company_id=${company_id}`, data),

  update: (id: number, data: AphisCatalogRecord, company_id: number) =>
    api.put<AphisCatalogRecord>(`/v1/a24/aphis-catalog/${id}?company_id=${company_id}`, data),

  delete: (id: number, company_id: number) =>
    api.delete(`/v1/a24/aphis-catalog/${id}?company_id=${company_id}`)
};
