diff --git a/app/applications/application-form.tsx b/app/applications/application-form.tsx index 6b26f8e..886e0e8 100644 --- a/app/applications/application-form.tsx +++ b/app/applications/application-form.tsx @@ -75,6 +75,10 @@ const applicationSchema = z campaignBlurb: z .string() .min(50, 'Please provide a detailed response (at least 50 characters)'), + bostonCampus: z.boolean({ + error: 'Please indicate if you will be on the Boston campus', + }), + bostonCampusExplanation: z.string().optional(), }) .refine( (data) => { @@ -85,6 +89,19 @@ const applicationSchema = z message: 'Constituency must be one of the selected colleges', path: ['constituency'], }, + ) + .refine( + (data) => { + // If not on Boston campus, explanation is required + if (data.bostonCampus === false) { + return data.bostonCampusExplanation && data.bostonCampusExplanation.trim().length > 0; + } + return true; + }, + { + message: 'Please explain your situation if you will not be on the Boston campus for the entirety of your term', + path: ['bostonCampusExplanation'], + }, ); type ApplicationFormData = z.infer; @@ -133,11 +150,13 @@ export default function ApplicationForm({ diversityEquityInclusionLongAnswer: '', conflictSituationLongAnswer: '', campaignBlurb: '', + bostonCampusExplanation: '', }, }); const colleges = watch('college'); const constituency = watch('constituency'); + const bostonCampus = watch('bostonCampus'); // Auto-select constituency if only one college is selected, clear if invalid useEffect(() => { @@ -795,6 +814,65 @@ export default function ApplicationForm({

)} + +
+ +
+ + +
+ {errors.bostonCampus && ( +

+ {errors.bostonCampus.message} +

+ )} +
+ + {bostonCampus === false && ( +
+ +