Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions components/organization/hackathons/rewards/types.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
9 changes: 8 additions & 1 deletion hooks/use-hackathon-rewards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 6 additions & 0 deletions lib/utils/rewards-data-mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 || '',
Expand Down
Loading