diff --git a/frontend/src/lib/components/crm/AccountFields.svelte b/frontend/src/lib/components/crm/AccountFields.svelte new file mode 100644 index 0000000..81d3757 --- /dev/null +++ b/frontend/src/lib/components/crm/AccountFields.svelte @@ -0,0 +1,53 @@ + + +{#if tab === 'generales'} +
+ + + + + + + + + +
+{:else if tab === 'comercial'} +
+ + + + + + +
+{:else if tab === 'fiscal'} +
+ + + + + + + + + +
+{:else if tab === 'observaciones'} +
+ + +
+{/if} diff --git a/frontend/src/lib/components/crm/RelatedManager.svelte b/frontend/src/lib/components/crm/RelatedManager.svelte index a548a2d..2a10584 100644 --- a/frontend/src/lib/components/crm/RelatedManager.svelte +++ b/frontend/src/lib/components/crm/RelatedManager.svelte @@ -11,8 +11,18 @@ import { ADDRESS_TYPES, DOC_TYPES, CONTACT_AREAS, labelOf } from '$lib/components/crm/format'; import { toast } from 'svelte-sonner'; - // Dueño de los registros relacionados: cliente (account) o proveedor (supplier) - let { ownerType, ownerId }: { ownerType: 'account' | 'supplier'; ownerId: number } = $props(); + // Dueño de los registros relacionados y qué sección mostrar + let { + ownerType, + ownerId, + section = 'all' + }: { + ownerType: 'account' | 'supplier'; + ownerId: number; + section?: 'addresses' | 'contacts' | 'documents' | 'all'; + } = $props(); + + const show = (s: 'addresses' | 'contacts' | 'documents') => section === 'all' || section === s; let addresses = $state([]); let contacts = $state([]); @@ -120,93 +130,96 @@
- - - - Direcciones - - - - {#if addresses.length === 0} -

Sin direcciones.

- {:else} - - TipoDomicilioCPCiudad - - {#each addresses as a (a.id)} - - {labelOf(ADDRESS_TYPES, a.address_type)}{#if a.is_primary}(principal){/if} - {[a.street, a.ext_number, a.neighborhood].filter(Boolean).join(' ') || '—'} - {a.postal_code ?? '—'} - {[a.city, a.state].filter(Boolean).join(', ') || '—'} - - - {/each} - - - {/if} -
-
+ {#if show('addresses')} + + + Direcciones + + + + {#if addresses.length === 0} +

Sin direcciones.

+ {:else} + + TipoDomicilioCPCiudad + + {#each addresses as a (a.id)} + + {labelOf(ADDRESS_TYPES, a.address_type)}{#if a.is_primary}(principal){/if} + {[a.street, a.ext_number, a.neighborhood].filter(Boolean).join(' ') || '—'} + {a.postal_code ?? '—'} + {[a.city, a.state].filter(Boolean).join(', ') || '—'} + + + {/each} + + + {/if} +
+
+ {/if} - - - - Contactos - - - - {#if contacts.length === 0} -

Sin contactos.

- {:else} - - NombrePuesto / ÁreaEmailTeléfono - - {#each contacts as c (c.id)} - - {c.first_name} {c.last_name ?? ''}{#if c.is_primary}(principal){/if} - {[c.job_title, labelOf(CONTACT_AREAS, c.area) !== '—' ? labelOf(CONTACT_AREAS, c.area) : null].filter(Boolean).join(' · ') || '—'} - {c.email ?? '—'} - {c.phone ?? c.mobile ?? '—'} - - - {/each} - - - {/if} -
-
+ {#if show('contacts')} + + + Contactos + + + + {#if contacts.length === 0} +

Sin contactos.

+ {:else} + + NombrePuesto / ÁreaEmailTeléfono + + {#each contacts as c (c.id)} + + {c.first_name} {c.last_name ?? ''}{#if c.is_primary}(principal){/if} + {[c.job_title, labelOf(CONTACT_AREAS, c.area) !== '—' ? labelOf(CONTACT_AREAS, c.area) : null].filter(Boolean).join(' · ') || '—'} + {c.email ?? '—'} + {c.phone ?? c.mobile ?? '—'} + + + {/each} + + + {/if} +
+
+ {/if} - - - - Documentos - - - - {#if documents.length === 0} -

Sin documentos.

- {:else} - - TipoNombreArchivo - - {#each documents as d (d.id)} - - {labelOf(DOC_TYPES, d.doc_type)} - {d.name} - {#if d.file_url}Ver{:else}—{/if} - - - {/each} - - - {/if} -
-
+ {#if show('documents')} + + + Documentos + + + + {#if documents.length === 0} +

Sin documentos.

+ {:else} + + TipoNombreArchivo + + {#each documents as d (d.id)} + + {labelOf(DOC_TYPES, d.doc_type)} + {d.name} + {#if d.file_url}Ver{:else}—{/if} + + + {/each} + + + {/if} +
+
+ {/if}
{#if activeModal}