Conversation
There was a problem hiding this comment.
Pull request overview
This pull request implements a panel judging opt-in feature that allows judges to explicitly choose whether they want to participate in judging panels. The PR addresses a database validation issue where the "Best Hack for Social Good" track doesn't have an associated domain, which was breaking panel creation.
Changes:
- Added
opted_into_panelsboolean field to users collection for judges to opt into panel assignments - Modified panels schema to make the
domainfield optional (allowing empty strings for tracks without domains) - Updated judge check-in flow and admin interface to allow judges to opt in/out of panel judging
Reviewed changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 8 comments.
Show a summary per file
| File | Description |
|---|---|
| migrations/20250930042214-add-opted-into-panels-to-users.mjs | Adds opted_into_panels field to users collection validator and sets default value to false for existing users |
| migrations/20250930045209-fix-panels-domain-validation.mjs | Updates panels validator to make domain field optional, allowing empty strings for tracks without domains |
| app/_types/user.ts | Adds optional opted_into_panels boolean field to User interface |
| app/_types/panel.ts | Changes domain field from required to optional in Panel interface |
| app/(pages)/judges/_components/AuthForms/CheckInForm.tsx | Adds checkbox for panel opt-in during judge check-in |
| app/(pages)/admin/_components/Judges/JudgeForm.tsx | Adds dropdown to admin form for managing judge panel opt-in status and improves team mapping logic |
| app/(pages)/admin/_components/Judges/JudgeCard.tsx | Displays panel opt-in status on judge cards |
| app/(pages)/_hooks/useAuthForm.ts | Updates hook to handle checkbox inputs with boolean values |
| app/(pages)/_components/AuthForm/AuthForm.tsx | Adds checkbox input support to generic auth form component |
| app/(api)/_utils/matching/judgeToPanelAlgorithm.ts | Updates algorithm to handle optional domain field using nullish coalescing |
| app/(api)/_actions/logic/assignJudgesToPanels.ts | Filters judges by opted_into_panels flag when assigning to panels |
| app/(api)/_actions/auth/verifyCode.ts | Updates check-in logic to optionally set opted_into_panels field |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (data?._id && data.teams) { | ||
| data.teams = data.teams | ||
| .map((team: any) => { | ||
| // Handle case where team might be just an ID string or already be a full team object | ||
| if (typeof team === 'string') { | ||
| return teamMap[team] || team; | ||
| } | ||
| return team._id ? teamMap[team._id] || team : team; | ||
| }) | ||
| .filter(Boolean); // Remove any undefined teams | ||
| } |
There was a problem hiding this comment.
The team mapping logic has been updated to handle both team ID strings and full team objects. However, the condition data?._id && data.teams means this mapping only occurs when editing an existing judge (one with an _id). For new judges being created, if data.teams exists but data._id doesn't, teams won't be mapped. Consider whether this is intentional or if the mapping should also apply when creating new judges if they somehow have teams assigned.
I'm fairly sure this works.
I've tested it on the mock data I have from old testing with only tech team as judges and it seemed to work for panel creation (I temporarily removed the limits on how many panels a judge can be on).
Have also added a dropdown to the Admin page for judges to allow changing of panel judging opt in.
I did have to make the 'domain' optional on panels, since the "Best Hack for Social Good" does not have a domain, do not know how this didn't break the panel judging before... but it is something to keep in mind if we run into problems later.
Have not checked the judge check in form part yet.