diff --git a/src/components/features/evaluator/applicant-list.tsx b/src/components/features/evaluator/applicant-list.tsx index 8c2f7d1..2157bd4 100644 --- a/src/components/features/evaluator/applicant-list.tsx +++ b/src/components/features/evaluator/applicant-list.tsx @@ -26,7 +26,18 @@ export function ApplicantList() { const filteredApplicants = useMemo(() => { let list = applicants || []; list = filterApplicantsByStatus(list, selectedStatuses); - return filterApplicantsBySearch(list, searchTerm).sort((a, b) => a._id.localeCompare(b._id)); + return filterApplicantsBySearch(list, searchTerm) + .slice() + .sort((a, b) => { + const aSubmissionMs = a.submission?.submittedAt?.toMillis?.() ?? 0; + const bSubmissionMs = b.submission?.submittedAt?.toMillis?.() ?? 0; + + if (aSubmissionMs !== bSubmissionMs) { + return aSubmissionMs - bSubmissionMs; + } + + return a._id.localeCompare(b._id); + }); }, [applicants, searchTerm, selectedStatuses]); return ( diff --git a/src/components/features/stampbook/export-raffle-dialog.tsx b/src/components/features/stampbook/export-raffle-dialog.tsx index 7c08b7d..6466b52 100644 --- a/src/components/features/stampbook/export-raffle-dialog.tsx +++ b/src/components/features/stampbook/export-raffle-dialog.tsx @@ -76,7 +76,7 @@ export function ExportRaffleDialog({ open, onClose, stamps }: ExportRaffleDialog setLoading(true); try { - const allUserStamps = await fetchHackersWithStamps(); + const allUserStamps = await fetchHackersWithStamps(selectedHackathon); const filteredEntries = allUserStamps.filter((entry: HackerStampEntry) => selectedStampIds.includes(entry.stampId) ); diff --git a/src/lib/firebase/types.ts b/src/lib/firebase/types.ts index fb3add5..50c8f7c 100644 --- a/src/lib/firebase/types.ts +++ b/src/lib/firebase/types.ts @@ -260,6 +260,7 @@ export interface Applicant { submission?: { lastUpdated?: Timestamp; submitted?: boolean; + submittedAt?: Timestamp; }; dayOf?: { day1?: { diff --git a/src/services/stamps.ts b/src/services/stamps.ts index 1f3869a..f79c86f 100644 --- a/src/services/stamps.ts +++ b/src/services/stamps.ts @@ -144,7 +144,7 @@ export const deleteStampQR = async (stampId: string) => { * Each stamp a user has unlocked creates one entry (for nwHacks 2026 raffle weighting). * @returns Array of entries where each entry represents one stamp collected by a hacker */ -export const fetchHackersWithStamps = async (): Promise => { +export const fetchHackersWithStamps = async (hackathonId: string): Promise => { const socialsSnapshot = await getDocs(collection(db, "Socials")); const entries: HackerStampEntry[] = []; @@ -152,7 +152,7 @@ export const fetchHackersWithStamps = async (): Promise => { const socialData = socialDoc.data(); const displayName = socialData.preferredName || "User"; const email = socialData.email || ""; - const unlockedStamps: string[] = socialData.unlockedStamps || []; + const unlockedStamps: string[] = socialData.unlockedStamps?.[hackathonId] || []; for (const stampId of unlockedStamps) { entries.push({