diff --git a/apps/web/src/routes/(dashboard)/compras/+page.svelte b/apps/web/src/routes/(dashboard)/compras/+page.svelte index 84052db..3e91175 100644 --- a/apps/web/src/routes/(dashboard)/compras/+page.svelte +++ b/apps/web/src/routes/(dashboard)/compras/+page.svelte @@ -1,5 +1,5 @@ @@ -27,7 +27,7 @@
@@ -35,10 +35,44 @@
-

Produtos

+

Objetos

- Cadastro, listagem e edição de produtos e serviços disponíveis para compra. + Cadastro, listagem e edição de objetos e serviços disponíveis para compra. +

+
+ + + +
+
+
+ +
+

Atas de Registro

+
+

+ Gerencie Atas de Registro de Preços e seus vínculos com objetos. +

+
+
+ + +
+
+
+ +
+

Empresas

+
+

+ Cadastro e gestão de empresas fornecedoras e seus contatos.

diff --git a/apps/web/src/routes/(dashboard)/compras/objetos/+page.svelte b/apps/web/src/routes/(dashboard)/compras/objetos/+page.svelte index 70b425e..05d1fdd 100644 --- a/apps/web/src/routes/(dashboard)/compras/objetos/+page.svelte +++ b/apps/web/src/routes/(dashboard)/compras/objetos/+page.svelte @@ -7,12 +7,15 @@ const client = useConvexClient(); - // Reactive query + // Reactive queries const objetosQuery = useQuery(api.objetos.list, {}); let objetos = $derived(objetosQuery.data || []); let loading = $derived(objetosQuery.isLoading); let error = $derived(objetosQuery.error?.message || null); + const atasQuery = useQuery(api.atas.list, {}); + let atas = $derived(atasQuery.data || []); + // Modal state let showModal = $state(false); let editingId: string | null = $state(null); @@ -23,13 +26,16 @@ codigoEfisco: '', codigoCatmat: '', codigoCatserv: '', - unidade: '' + unidade: '', + atas: [] as Id<'atas'>[] }); let saving = $state(false); - function openModal(objeto?: Doc<'objetos'>) { + async function openModal(objeto?: Doc<'objetos'>) { if (objeto) { editingId = objeto._id; + // Fetch linked Atas + const linkedAtas = await client.query(api.objetos.getAtas, { objetoId: objeto._id }); formData = { nome: objeto.nome, valorEstimado: maskCurrencyBRL(objeto.valorEstimado || ''), @@ -37,7 +43,8 @@ codigoEfisco: objeto.codigoEfisco || '', codigoCatmat: objeto.codigoCatmat || '', codigoCatserv: objeto.codigoCatserv || '', - unidade: objeto.unidade || '' + unidade: objeto.unidade || '', + atas: linkedAtas.map((a) => a._id) }; } else { editingId = null; @@ -48,7 +55,8 @@ codigoEfisco: '', codigoCatmat: '', codigoCatserv: '', - unidade: '' + unidade: '', + atas: [] }; } showModal = true; @@ -70,7 +78,8 @@ codigoEfisco: formData.codigoEfisco, codigoCatmat: formData.codigoCatmat || undefined, codigoCatserv: formData.codigoCatserv || undefined, - unidade: formData.unidade + unidade: formData.unidade, + atas: formData.atas }; if (editingId) { @@ -97,6 +106,14 @@ alert('Erro ao excluir: ' + (e as Error).message); } } + + function toggleAtaSelection(ataId: Id<'atas'>) { + if (formData.atas.includes(ataId)) { + formData.atas = formData.atas.filter((id) => id !== ataId); + } else { + formData.atas = [...formData.atas, ataId]; + } + }
@@ -303,6 +320,31 @@ />
+
+ +
+ {#each atas as ata (ata._id)} +
+ toggleAtaSelection(ata._id)} + class="mr-2 h-4 w-4 rounded border-gray-300 text-blue-600 focus:ring-blue-500" + /> + +
+ {/each} + {#if atas.length === 0} +

Nenhuma ata disponível.

+ {/if} +
+
+