- Introduced a modal for managing user profiles, allowing for the creation and editing of profiles with improved state management. - Updated the role filtering logic to enhance type safety and readability. - Refactored UI components for better user experience, including improved button states and loading indicators. - Removed outdated code related to permissions and streamlined the overall structure for maintainability.
46 lines
860 B
TypeScript
46 lines
860 B
TypeScript
import { v } from "convex/values";
|
|
import { query } from "./_generated/server";
|
|
|
|
/**
|
|
* Listar todas as roles
|
|
*/
|
|
export const listar = query({
|
|
args: {},
|
|
returns: v.array(
|
|
v.object({
|
|
_id: v.id("roles"),
|
|
_creationTime: v.number(),
|
|
nome: v.string(),
|
|
descricao: v.string(),
|
|
nivel: v.number(),
|
|
setor: v.optional(v.string()),
|
|
})
|
|
),
|
|
handler: async (ctx) => {
|
|
return await ctx.db.query("roles").collect();
|
|
},
|
|
});
|
|
|
|
/**
|
|
* Buscar role por ID
|
|
*/
|
|
export const buscarPorId = query({
|
|
args: {
|
|
roleId: v.id("roles"),
|
|
},
|
|
returns: v.union(
|
|
v.object({
|
|
_id: v.id("roles"),
|
|
nome: v.string(),
|
|
descricao: v.string(),
|
|
nivel: v.number(),
|
|
setor: v.optional(v.string()),
|
|
}),
|
|
v.null()
|
|
),
|
|
handler: async (ctx, args) => {
|
|
return await ctx.db.get(args.roleId);
|
|
},
|
|
});
|
|
|