import { adaptPendingReviews } from "@/lib/adapters/reviews"; import { backendRequest } from "@/lib/http/backend-client"; import { jsonSuccess, withErrorHandling } from "@/lib/http/response"; import type { PendingReviewResponseDto, WorkflowStatusResponseDto, } from "@/lib/types/backend"; import { adaptWorkflowDetail } from "@/lib/adapters/workflows"; import type { ReviewQueueItemVM } from "@/lib/types/view-models"; async function enrichQueueItem( item: ReviewQueueItemVM, ): Promise { try { const workflowResponse = await backendRequest( `/workflows/${item.orderId}`, ); const workflow = adaptWorkflowDetail(workflowResponse.data); return { ...item, workflowType: workflow.workflowType, hasMockAssets: workflow.hasMockAssets, failureCount: workflow.failureCount, }; } catch { return item; } } export async function GET(request: Request) { return withErrorHandling(async () => { void request; const response = await backendRequest( "/reviews/pending", ); const queue = adaptPendingReviews(response.data); const items = await Promise.all(queue.items.map(enrichQueueItem)); return jsonSuccess( { ...queue, items, }, { mode: "proxy", }, ); }); }