refactor: improve type safety and error handling in vacation management components

- Updated the `AprovarFerias.svelte` component to use specific types for `solicitacao` and `gestorId`, enhancing type safety.
- Improved error handling by refining catch blocks to handle errors more accurately.
- Made minor adjustments to ensure consistent code formatting and readability across the component.
This commit is contained in:
2025-10-31 13:39:41 -03:00
parent 5dec7d7da7
commit 5cb63f9437
20 changed files with 155 additions and 112 deletions

View File

@@ -165,7 +165,7 @@ export const assertPermissaoAcaoAtual = internalQuery({
returns: v.null(),
handler: async (ctx, args) => {
const identity = await ctx.auth.getUserIdentity();
let usuarioAtual: any = null;
let usuarioAtual: Doc<"usuarios"> | null = null;
if (identity && identity.email) {
usuarioAtual = await ctx.db
@@ -187,9 +187,9 @@ export const assertPermissaoAcaoAtual = internalQuery({
if (!usuarioAtual) throw new Error("acesso_negado");
const role: any = await ctx.db.get(usuarioAtual.roleId as any);
const role = await ctx.db.get(usuarioAtual.roleId);
if (!role) throw new Error("acesso_negado");
if ((role as any).nivel <= 1) return null;
if (role.nivel <= 1) return null;
const permissao = await ctx.db
.query("permissoes")
@@ -201,7 +201,7 @@ export const assertPermissaoAcaoAtual = internalQuery({
const links = await ctx.db
.query("rolePermissoes")
.withIndex("by_role", (q) => q.eq("roleId", (role as any)._id as any))
.withIndex("by_role", (q) => q.eq("roleId", role._id))
.collect();
const ok = links.some((rp) => rp.permissaoId === permissao!._id);
if (!ok) throw new Error("acesso_negado");