refactor: enhance Sidebar layout with fixed header and footer, improve dashboard layout, and implement symbol management features including deletion and data display
This commit is contained in:
@@ -3,11 +3,46 @@ import { query, mutation } from "./_generated/server";
|
||||
import { simboloTipo } from "./schema";
|
||||
|
||||
export const getAll = query({
|
||||
args: {},
|
||||
returns: v.array(
|
||||
v.object({
|
||||
_id: v.id("simbolos"),
|
||||
_creationTime: v.number(),
|
||||
nome: v.string(),
|
||||
tipo: simboloTipo,
|
||||
descricao: v.string(),
|
||||
vencValor: v.string(),
|
||||
repValor: v.string(),
|
||||
valor: v.string(),
|
||||
})
|
||||
),
|
||||
handler: async (ctx) => {
|
||||
return await ctx.db.query("simbolos").collect();
|
||||
},
|
||||
});
|
||||
|
||||
export const getById = query({
|
||||
args: {
|
||||
id: v.id("simbolos"),
|
||||
},
|
||||
returns: v.union(
|
||||
v.object({
|
||||
_id: v.id("simbolos"),
|
||||
_creationTime: v.number(),
|
||||
nome: v.string(),
|
||||
tipo: simboloTipo,
|
||||
descricao: v.string(),
|
||||
vencValor: v.string(),
|
||||
repValor: v.string(),
|
||||
valor: v.string(),
|
||||
}),
|
||||
v.null()
|
||||
),
|
||||
handler: async (ctx, args) => {
|
||||
return await ctx.db.get(args.id);
|
||||
},
|
||||
});
|
||||
|
||||
export const create = mutation({
|
||||
args: {
|
||||
nome: v.string(),
|
||||
@@ -48,3 +83,58 @@ export const create = mutation({
|
||||
return await ctx.db.get(novoSimboloId);
|
||||
},
|
||||
});
|
||||
|
||||
export const remove = mutation({
|
||||
args: {
|
||||
id: v.id("simbolos"),
|
||||
},
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
await ctx.db.delete(args.id);
|
||||
return null;
|
||||
},
|
||||
});
|
||||
|
||||
export const update = mutation({
|
||||
args: {
|
||||
id: v.id("simbolos"),
|
||||
nome: v.string(),
|
||||
tipo: simboloTipo,
|
||||
refValor: v.string(),
|
||||
vencValor: v.string(),
|
||||
descricao: v.string(),
|
||||
valor: v.optional(v.string()),
|
||||
},
|
||||
returns: v.null(),
|
||||
handler: async (ctx, args) => {
|
||||
let refValor = args.refValor;
|
||||
let vencValor = args.vencValor;
|
||||
let valor = args.valor ?? "";
|
||||
|
||||
if (args.tipo === "cargo_comissionado") {
|
||||
if (!refValor || !vencValor) {
|
||||
throw new Error(
|
||||
"Valor de referência e valor de vencimento são obrigatórios para cargo comissionado"
|
||||
);
|
||||
}
|
||||
valor = (Number(refValor) + Number(vencValor)).toFixed(2);
|
||||
} else {
|
||||
if (!args.valor) {
|
||||
throw new Error("Valor é obrigatório para função gratificada");
|
||||
}
|
||||
refValor = "";
|
||||
vencValor = "";
|
||||
valor = args.valor;
|
||||
}
|
||||
|
||||
await ctx.db.patch(args.id, {
|
||||
nome: args.nome,
|
||||
descricao: args.descricao,
|
||||
repValor: refValor,
|
||||
vencValor: vencValor,
|
||||
tipo: args.tipo,
|
||||
valor,
|
||||
});
|
||||
return null;
|
||||
},
|
||||
});
|
||||
Reference in New Issue
Block a user