feat: enhance pedidos functionality by adding new submenu options for creating and planning orders, improving user navigation and access control in the sidebar; also implement URL-based prefill for adding items, ensuring a smoother user experience when creating pedidos

This commit is contained in:
2025-12-17 21:42:35 -03:00
parent 551a2fed00
commit 69914170bf
12 changed files with 1896 additions and 97 deletions

View File

@@ -0,0 +1,45 @@
import { defineTable } from 'convex/server';
import { v } from 'convex/values';
export const planejamentosTables = {
planejamentosPedidos: defineTable({
titulo: v.string(),
descricao: v.string(),
// Armazenar como yyyy-MM-dd para facilitar input type="date" no frontend.
data: v.string(),
responsavelId: v.id('funcionarios'),
acaoId: v.optional(v.id('acoes')),
status: v.union(v.literal('rascunho'), v.literal('gerado'), v.literal('cancelado')),
criadoPor: v.id('usuarios'),
criadoEm: v.number(),
atualizadoEm: v.number()
})
.index('by_responsavelId', ['responsavelId'])
.index('by_status', ['status'])
.index('by_criadoEm', ['criadoEm']),
planejamentoItens: defineTable({
planejamentoId: v.id('planejamentosPedidos'),
// Opcional no cadastro; obrigatório para gerar pedidos.
numeroDfd: v.optional(v.string()),
objetoId: v.id('objetos'),
quantidade: v.number(),
valorEstimado: v.string(),
// Preenchido após a geração (itens foram materializados no pedido).
pedidoId: v.optional(v.id('pedidos')),
criadoEm: v.number(),
atualizadoEm: v.number()
})
.index('by_planejamentoId', ['planejamentoId'])
.index('by_planejamentoId_and_numeroDfd', ['planejamentoId', 'numeroDfd']),
planejamentoPedidosLinks: defineTable({
planejamentoId: v.id('planejamentosPedidos'),
numeroDfd: v.string(),
pedidoId: v.id('pedidos'),
criadoEm: v.number()
})
.index('by_planejamentoId', ['planejamentoId'])
.index('by_pedidoId', ['pedidoId'])
.index('by_planejamentoId_and_numeroDfd', ['planejamentoId', 'numeroDfd'])
};