diff --git a/components/organization/hackathons/rewards/types.ts b/components/organization/hackathons/rewards/types.ts index 0633aaaf..788d1adf 100644 --- a/components/organization/hackathons/rewards/types.ts +++ b/components/organization/hackathons/rewards/types.ts @@ -1,5 +1,12 @@ export interface Submission { id: string; + /** + * The actual HackathonSubmission row ID, distinct from `id` which the + * rewards data mapper sets to the participant ID. Required for + * matching submissions against backend payloads (judging results, + * track winners) that key by submissionId. + */ + submissionId?: string; name: string; projectName: string; avatar?: string; diff --git a/hooks/use-hackathon-rewards.ts b/hooks/use-hackathon-rewards.ts index 2b4a8fe4..ec4240cd 100644 --- a/hooks/use-hackathon-rewards.ts +++ b/hooks/use-hackathon-rewards.ts @@ -472,7 +472,14 @@ export const useHackathonRewards = ( const byId = new Map(fetched.map(tw => [tw.submissionId, tw])); setSubmissions(prev => prev.map(sub => { - const tw = byId.get(sub.id); + // Match against the real submission row ID (now threaded + // through by the mapper). Fall back to `sub.id` for any + // mapper output that predates the `submissionId` field — + // older rows would have `id === submissionId` when + // participant data was missing. + const tw = + (sub.submissionId && byId.get(sub.submissionId)) || + byId.get(sub.id); if (!tw) return sub; return { ...sub, diff --git a/lib/utils/rewards-data-mapper.ts b/lib/utils/rewards-data-mapper.ts index a423640e..67137675 100644 --- a/lib/utils/rewards-data-mapper.ts +++ b/lib/utils/rewards-data-mapper.ts @@ -63,6 +63,12 @@ export const mapJudgingSubmissionToRewardSubmission = ( return { id: participant.id || sub.id || '', + // The real submission row ID, used by backend payloads (judging + // results, track winners) that key by submissionId. The mapper's + // `id` field stays on the participant ID for compatibility with + // existing rank-assignment and display code that already keys off + // it. + submissionId: submissionData.id || sub.id || sub.submissionId || '', participantId: participant.id || sub.id || '', name, projectName: submissionData.projectName || '',