diff --git a/src/components/admin/round/project-states-table.tsx b/src/components/admin/round/project-states-table.tsx index 7ad483f..71bd251 100644 --- a/src/components/admin/round/project-states-table.tsx +++ b/src/components/admin/round/project-states-table.tsx @@ -330,7 +330,7 @@ export function ProjectStatesTable({ competitionId, roundId }: ProjectStatesTabl {/* Table */}
{/* Header */} -
+
0 && filtered.every((ps: any) => selectedIds.has(ps.projectId))} @@ -339,6 +339,7 @@ export function ProjectStatesTable({ competitionId, roundId }: ProjectStatesTabl
Project
Category
+
Country
State
Entered
@@ -351,7 +352,7 @@ export function ProjectStatesTable({ competitionId, roundId }: ProjectStatesTabl return (
+
+ {ps.project?.country || '—'} +
diff --git a/src/server/routers/specialAward.ts b/src/server/routers/specialAward.ts index 41b7dd0..3e22604 100644 --- a/src/server/routers/specialAward.ts +++ b/src/server/routers/specialAward.ts @@ -4,6 +4,25 @@ import { Prisma } from '@prisma/client' import { router, protectedProcedure, adminProcedure } from '../trpc' import { logAudit } from '../utils/audit' import { processEligibilityJob } from '../services/award-eligibility-job' +import type { PrismaClient } from '@prisma/client' + +/** + * Verify the current session user exists in the database. + * Guards against stale JWT sessions (e.g., after database reseed). + */ +async function ensureUserExists(db: PrismaClient, userId: string): Promise { + const user = await db.user.findUnique({ + where: { id: userId }, + select: { id: true }, + }) + if (!user) { + throw new TRPCError({ + code: 'UNAUTHORIZED', + message: 'Your session refers to a user that no longer exists. Please log out and log back in.', + }) + } + return user.id +} export const specialAwardRouter = router({ // ─── Admin Queries ────────────────────────────────────────────────────── @@ -425,6 +444,8 @@ export const specialAwardRouter = router({ }) ) .mutation(async ({ ctx, input }) => { + const verifiedUserId = await ensureUserExists(ctx.prisma, ctx.user.id) + await ctx.prisma.awardEligibility.upsert({ where: { awardId_projectId: { @@ -433,16 +454,16 @@ export const specialAwardRouter = router({ }, }, create: { - awardId: input.awardId, - projectId: input.projectId, + award: { connect: { id: input.awardId } }, + project: { connect: { id: input.projectId } }, eligible: input.eligible, method: 'MANUAL', - overriddenBy: ctx.user.id, + overriddenByUser: { connect: { id: verifiedUserId } }, overriddenAt: new Date(), }, update: { eligible: input.eligible, - overriddenBy: ctx.user.id, + overriddenByUser: { connect: { id: verifiedUserId } }, overriddenAt: new Date(), }, }) @@ -1018,12 +1039,14 @@ export const specialAwardRouter = router({ }) } + const verifiedUserId = await ensureUserExists(ctx.prisma, ctx.user.id) + // Mark all as confirmed await ctx.prisma.awardEligibility.updateMany({ where: { awardId: input.awardId, shortlisted: true, eligible: true }, data: { confirmedAt: new Date(), - confirmedBy: ctx.user.id, + confirmedBy: verifiedUserId, }, }) diff --git a/src/server/services/round-engine.ts b/src/server/services/round-engine.ts index 348085d..35fd6e2 100644 --- a/src/server/services/round-engine.ts +++ b/src/server/services/round-engine.ts @@ -690,6 +690,7 @@ export async function getProjectRoundStates( title: true, teamName: true, competitionCategory: true, + country: true, status: true, }, },