generated from nhcarrigan/template
feat: ability to edit suggestions when accepting
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user