export const pendingReviewsRoutes = async (fastify, opts) => {
    const { listPendingReviews, confirmPendingReview, dismissPendingReview, presenter } = opts;
    fastify.get('/api/pending-reviews', async () => {
        const pendingList = await listPendingReviews.execute();
        return { pendingReviews: pendingList.map((entry) => presenter.present(entry)) };
    });
    fastify.post('/api/pending-reviews/:pendingId/confirm', async (request, reply) => {
        const { pendingId } = request.params;
        const result = await confirmPendingReview.execute({ pendingId });
        if (result.status === 'not-found') {
            reply.code(404);
            return { status: 'not-found' };
        }
        if (result.status === 'already-running') {
            reply.code(409);
            return { status: 'already-running', message: result.message };
        }
        return { status: 'confirmed', jobId: result.jobId };
    });
    fastify.delete('/api/pending-reviews/:pendingId', async (request, reply) => {
        const { pendingId } = request.params;
        const result = await dismissPendingReview.execute({ pendingId });
        if (result.status === 'not-found') {
            reply.code(404);
            return { status: 'not-found' };
        }
        if (result.status === 'already-running') {
            reply.code(409);
            return { status: 'already-running', message: result.message };
        }
        return { status: 'dismissed' };
    });
};
//# sourceMappingURL=pendingReviews.routes.js.map