feat: ability to edit suggestions when accepting

This commit is contained in:
2026-02-04 21:37:57 -08:00
parent 729f410443
commit 800b9f6c2d
5 changed files with 383 additions and 11 deletions
+34
View File
@@ -137,6 +137,40 @@ export default async function (app: FastifyInstance): Promise<void> {
}
);
// Accept a suggestion with edits (admin only)
app.put<{ Params: { id: string }; Body: any }>(
"/:id/accept-with-edits",
{
preHandler: [app.authenticate, adminGuard, app.csrfProtection],
},
async (request, reply) => {
const { id } = request.params;
const editedData = request.body;
try {
const suggestion = await SuggestionService.acceptSuggestionWithEdits(id, editedData);
await AuditService.log(
{
action: AuditAction.ENTRY_UPDATE,
category: AuditCategory.ADMIN,
resourceType: "Suggestion",
resourceId: suggestion.id,
details: `Accepted ${suggestion.entityType} suggestion with edits: ${suggestion.title}`,
success: true,
},
request
);
reply.send(suggestion);
} catch (error) {
return reply.badRequest(
error instanceof Error ? error.message : "Failed to accept suggestion with edits"
);
}
}
);
// Decline a suggestion (admin only)
app.put<{ Params: { id: string }; Body: DeclineSuggestionDto }>(
"/:id/decline",