import { serverListPendingReviewMatches, serverSetMatchReview, } from '@novelpad/outreach-core/server'; import { Form, Link } from 'react-router'; import { db } from '#~/db.server.js'; import type { Route } from './+types/_index.js'; export async function loader({ request }: Route.LoaderArgs) { if (request.method === 'HEAD') return; const matches = await serverListPendingReviewMatches(db); return { matches }; } export async function action({ request }: Route.ActionArgs) { if (request.method === 'HEAD') return; const formData = await request.formData(); const matchId = String(formData.get('matchId') ?? ''); const decision = formData.get('decision'); if (!matchId || (decision !== 'approved' && decision !== 'rejected')) { throw new Response('Invalid review submission', { status: 400 }); } await serverSetMatchReview(db, { matchId, reviewStatus: decision, rejectReason: decision === 'rejected' ? 'other' : undefined, }); return { ok: true as const }; } export default function ReviewQueue({ loaderData }: Route.ComponentProps) { const matches = loaderData?.matches ?? []; return (

Grant Match Review Queue

{matches.length === 0 ? (

No pending matches to review.

) : ( {matches.map((match) => ( ))}
Organization Grant Score Easy Win Actions
{match.orgName} {match.grantTitle} {match.totalScore} {match.easyWin ? 'Yes' : 'No'}
)}
); }