diff --git a/frontend/src/lib/api/crm/addresses.ts b/frontend/src/lib/api/crm/addresses.ts new file mode 100644 index 0000000..c8b79c1 --- /dev/null +++ b/frontend/src/lib/api/crm/addresses.ts @@ -0,0 +1,36 @@ +/** + * Cliente API — Direcciones CRM (de un cliente o proveedor) + */ +import { api } from '$lib/api'; +import type { Address, AddressInput } from './types'; + +export const addressesAPI = { + async list( + companyId: number, + params?: { account_id?: number; supplier_id?: number } + ): Promise
{ + const qs = new URLSearchParams({ company_id: String(companyId) }); + if (params?.account_id) qs.set('account_id', String(params.account_id)); + if (params?.supplier_id) qs.set('supplier_id', String(params.supplier_id)); + const res = await api.get(`/v1/crm/addresses?${qs}`); + if (res.error) throw new Error(res.error); + return res.data!; + }, + + async create(data: AddressInput, companyId: number): Promise { + const res = await api.post(`/v1/crm/addresses?company_id=${companyId}`, data); + if (res.error) throw new Error(res.error); + return res.data!; + }, + + async update(id: number, data: PartialSin direcciones.
+ {:else} +Sin contactos.
+ {:else} +Sin documentos.
+ {:else} +Empresas cliente y prospectos.
+Catálogo de clientes y prospectos.
Cargando…
{:else if filtered.length === 0} -Sin cuentas registradas.
+Sin registros.
{:else}