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
1 change: 1 addition & 0 deletions src/lib/firebase/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ export interface Applicant {
gender: string | Record<string, boolean>;
graduation: number;
isOfLegalAge: boolean;
ageByHackathon: string;
location: string; // city
major: ApplicantMajor | Record<string, boolean>;
phoneNumber: string; // "+1 XXX-XXX-XXXX"
Expand Down
12 changes: 11 additions & 1 deletion src/services/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,15 @@ export const flattenApplicantData = (applicant: Applicant, hackathon?: string):
const hackathonYear = year ? Number.parseInt(year) : 2025;
const isLegacyFormat = hackathonYear < 2024 || hackathon === "nwHacks2024";

const computedIsOfLegalAge = (applicant: Applicant) => {
const rawAge = applicant.basicInfo?.ageByHackathon
if (rawAge == "<=16") return false
if (rawAge == ">24") return true

const numericAge = typeof rawAge === "number" ? rawAge : Number(rawAge)
return numericAge >= 19
}

const flattened: FlattenedApplicant = {
// Basic Info
firstName: applicant.basicInfo?.legalFirstName || applicant.basicInfo?.firstName || "",
Expand All @@ -55,7 +64,7 @@ export const flattenApplicantData = (applicant: Applicant, hackathon?: string):
applicant.basicInfo?.gender as Record<string, boolean> | undefined,
''
),
isOfLegalAge: applicant.basicInfo?.isOfLegalAge || false,
isOfLegalAge: computedIsOfLegalAge(applicant),
culturalBackground: returnTrueKey(applicant.basicInfo?.ethnicity || applicant.basicInfo?.culturalBackground),
dietaryRestriction: createStringFromSelection(
applicant.basicInfo?.dietaryRestriction,
Expand Down Expand Up @@ -148,6 +157,7 @@ export const getAvailableColumns = (): string[] => {
gender: "",
location: "",
isOfLegalAge: true,
ageByHackathon: "0",
ethnicity: {
asian: false,
black: false,
Expand Down