feat: Implement order acceptance and analysis workflows with new pages, sidebar navigation, and backend queries for filtering and permissions.
This commit is contained in:
@@ -44,6 +44,31 @@ export const getUserPermissions = query({
|
||||
}
|
||||
}
|
||||
|
||||
// Injetar permissão de aceitar pedidos se o usuário for do setor de compras
|
||||
const config = await ctx.db.query('config').first();
|
||||
if (config && config.comprasSetorId) {
|
||||
let funcionario = null;
|
||||
if (usuario.funcionarioId) {
|
||||
funcionario = await ctx.db.get(usuario.funcionarioId);
|
||||
}
|
||||
|
||||
if (funcionario) {
|
||||
// Verificar se o funcionário está no setor de compras
|
||||
// Precisamos verificar na tabela funcionarioSetores ou se o setorId está no funcionario (depende da modelagem)
|
||||
// Olhando para tables/funcionarios.ts, parece que não tem setorId direto, é N:N?
|
||||
// Vamos verificar funcionarioSetores.
|
||||
const funcionarioSetor = await ctx.db
|
||||
.query('funcionarioSetores')
|
||||
.withIndex('by_funcionarioId', (q) => q.eq('funcionarioId', funcionario._id))
|
||||
.filter((q) => q.eq(q.field('setorId'), config.comprasSetorId))
|
||||
.first();
|
||||
|
||||
if (funcionarioSetor) {
|
||||
permissions.push('pedidos.aceitar');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return { isMaster: false, permissions };
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user