import { api } from '$lib/api'; import type { ApiResponse } from '$lib/api'; export interface Company { id: number; tenant_id: number; name: string | null; rfc: string | null; main_activity: string | null; program: string | null; program_number: string | null; prosec: number | null; prosec_authorization: string | null; manufacturer_id: string | null; broker_company: string | null; responsible: string | null; responsible_name: string | null; responsible_last_name: string | null; responsible_mother_last_name: string | null; created_at: string | null; updated_at: string | null; } export interface CompanyCreate { name?: string | null; rfc?: string | null; main_activity?: string | null; program?: string | null; program_number?: string | null; prosec?: number | null; prosec_authorization?: string | null; manufacturer_id?: string | null; broker_company?: string | null; responsible?: string | null; responsible_name?: string | null; responsible_last_name?: string | null; responsible_mother_last_name?: string | null; } export interface CompanyUpdate { name?: string | null; rfc?: string | null; main_activity?: string | null; program?: string | null; program_number?: string | null; prosec?: number | null; prosec_authorization?: string | null; manufacturer_id?: string | null; broker_company?: string | null; responsible?: string | null; responsible_name?: string | null; responsible_last_name?: string | null; responsible_mother_last_name?: string | null; } export interface CompanyListResponse { items: Company[]; total: number; page: number; page_size: number; pages: number; } export async function getCompanies( page = 1, pageSize = 50, filters: Record = {} ): Promise> { const queryParams = new URLSearchParams({ page: page.toString(), page_size: pageSize.toString(), ...filters }); return await api.get(`/a76/company?${queryParams.toString()}`); } export async function getCompany(id: number): Promise> { return await api.get(`/a76/company/${id}`); } export async function createCompany(data: CompanyCreate): Promise> { return await api.post(`/a76/company`, data); } export async function updateCompany(id: number, data: CompanyUpdate): Promise> { return await api.put(`/a76/company/${id}`, data); } export async function deleteCompany(id: number): Promise> { return await api.delete(`/a76/company/${id}`); }