feat: add report printing and deletion functionality

- Implemented a new feature to print security reports with structured JSON observations, enhancing report accessibility.
- Added a deletion function for reports, allowing users to remove reports with confirmation prompts.
- Updated the CybersecurityWizcard component to include action buttons for printing and deleting reports, improving user interaction.
- Enhanced the backend with a mutation to handle report deletions, ensuring proper cleanup of associated artifacts.
This commit is contained in:
2025-11-16 08:24:58 -03:00
parent 70d405d98d
commit 60e0bfa69e
3 changed files with 142 additions and 2 deletions

View File

@@ -1301,6 +1301,31 @@ export const healthStatus = query({
};
}
});
/**
* Excluir relatório gerado (e artefato, se houver)
*/
export const deletarRelatorio = mutation({
args: {
relatorioId: v.id('reportRequests')
},
returns: v.object({ success: v.boolean() }),
handler: async (ctx, args) => {
const doc = await ctx.db.get(args.relatorioId);
if (!doc) {
return { success: false };
}
// Remover arquivo em storage se existir
if (doc.resultadoId) {
try {
await ctx.storage.delete(doc.resultadoId);
} catch {
// Ignorar falha ao excluir artefato de storage
}
}
await ctx.db.delete(args.relatorioId);
return { success: true };
}
});
export const processarRelatorioSegurancaInternal = internalMutation({
args: {
relatorioId: v.id('reportRequests')