@@ -25,7 +25,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
25
25
import FormGroupWrapper from "./FormGroupWrapper" ;
26
26
import { Checkbox } from "@/components/shadcn/ui/checkbox" ;
27
27
import Link from "next/link" ;
28
- import c , { schools , majors } from "config" ;
28
+ import c from "config" ;
29
29
import {
30
30
Command ,
31
31
CommandEmpty ,
@@ -52,6 +52,7 @@ import { put, type PutBlobResult } from "@vercel/blob";
52
52
import { Tag , TagInput } from "@/components/shadcn/ui/tag/tag-input" ;
53
53
import CreatingRegistration from "./CreatingRegistration" ;
54
54
import { bucketResumeBaseUploadUrl } from "config" ;
55
+ import { count } from "console" ;
55
56
interface RegisterFormProps {
56
57
defaultEmail : string ;
57
58
}
@@ -91,6 +92,8 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
91
92
shirtSize : "" as any ,
92
93
schoolID : "" ,
93
94
university : "" ,
95
+ phoneNumber :"" ,
96
+ countryOfResidence :"" ,
94
97
} ,
95
98
} ) ;
96
99
@@ -103,16 +106,23 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
103
106
const [ isLoading , setIsLoading ] = useState ( false ) ;
104
107
const universityValue = form . watch ( "university" ) ;
105
108
const bioValue = form . watch ( "bio" ) ;
109
+ const countryValue = form . watch ( "countryOfResidence" ) ;
106
110
107
111
useEffect ( ( ) => {
108
- if ( universityValue != c . localUniversityName . toLowerCase ( ) ) {
112
+ if ( universityValue != c . localUniversityName ) {
109
113
form . setValue ( "schoolID" , "NOT_LOCAL_SCHOOL" ) ;
110
114
} else {
111
115
form . setValue ( "schoolID" , "" ) ;
112
116
}
113
117
} , [ universityValue ] ) ;
114
118
119
+
120
+ useEffect ( ( ) => {
121
+ console . log ( countryValue )
122
+ } , [ countryValue ] )
123
+
115
124
async function onSubmit ( data : z . infer < typeof RegisterFormValidator > ) {
125
+ console . log ( data ) ;
116
126
setIsLoading ( true ) ;
117
127
if ( ! userId || ! isLoaded ) {
118
128
setIsLoading ( false ) ;
@@ -168,6 +178,9 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
168
178
}
169
179
} else {
170
180
setIsLoading ( false ) ;
181
+ alert (
182
+ `Something went wrong while attempting to register. Please try again. If this is a continuing issue, please reach out to us at ${ c . issueEmail } .` ,
183
+ )
171
184
return console . log (
172
185
`Recieved a unexpected response from the server. Please try again. If this is a continuing issue, please reach out to us at ${ c . issueEmail } .` ,
173
186
) ;
@@ -208,7 +221,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
208
221
className = "space-y-6"
209
222
>
210
223
< FormGroupWrapper title = "General" >
211
- < div className = "grid grid-cols-1 gap-x-2 gap-y-2 md:grid-cols-3 md:gap-y-0 " >
224
+ < div className = "grid grid-cols-1 gap-x-2 gap-y-4 md:grid-cols-2 " >
212
225
< FormField
213
226
control = { form . control }
214
227
name = "firstName"
@@ -217,7 +230,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
217
230
< FormLabel > First Name</ FormLabel >
218
231
< FormControl >
219
232
< Input
220
- placeholder = "Some "
233
+ placeholder = "John "
221
234
{ ...field }
222
235
/>
223
236
</ FormControl >
@@ -233,7 +246,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
233
246
< FormLabel > Last Name</ FormLabel >
234
247
< FormControl >
235
248
< Input
236
- placeholder = "One "
249
+ placeholder = "Doe "
237
250
{ ...field }
238
251
/>
239
252
</ FormControl >
@@ -259,8 +272,24 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
259
272
</ FormItem >
260
273
) }
261
274
/>
275
+ < FormField
276
+ control = { form . control }
277
+ name = "phoneNumber"
278
+ render = { ( { field } ) => (
279
+ < FormItem >
280
+ < FormLabel > Phone Number</ FormLabel >
281
+ < FormControl >
282
+ < Input
283
+ placeholder = "555-555-5555"
284
+ { ...field }
285
+ />
286
+ </ FormControl >
287
+ < FormMessage />
288
+ </ FormItem >
289
+ ) }
290
+ />
262
291
</ div >
263
- < div className = "grid grid-cols-1 gap-x-2 gap-y-2 md:grid-cols-7 md:gap-y-0 " >
292
+ < div className = "grid grid-cols-1 gap-x-2 gap-y-4 md:grid-cols-2 " >
264
293
< FormField
265
294
control = { form . control }
266
295
name = "age"
@@ -278,7 +307,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
278
307
control = { form . control }
279
308
name = "gender"
280
309
render = { ( { field } ) => (
281
- < FormItem className = "col-span-2 " >
310
+ < FormItem className = "" >
282
311
< FormLabel > Gender</ FormLabel >
283
312
< Select
284
313
onValueChange = { field . onChange }
@@ -317,7 +346,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
317
346
control = { form . control }
318
347
name = "race"
319
348
render = { ( { field } ) => (
320
- < FormItem className = "col-span-2 " >
349
+ < FormItem className = "" >
321
350
< FormLabel > Race</ FormLabel >
322
351
< Select
323
352
onValueChange = { field . onChange }
@@ -330,25 +359,16 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
330
359
</ FormControl >
331
360
< SelectContent >
332
361
< SelectGroup >
333
- < SelectItem value = "Native American" >
334
- Native American
335
- </ SelectItem >
336
- < SelectItem value = "Asian / Pacific Islander" >
337
- Asian / Pacific Islander
338
- </ SelectItem >
339
- < SelectItem value = "Black or African American" >
340
- Black or African
341
- American
342
- </ SelectItem >
343
- < SelectItem value = "White / Caucasion" >
344
- White / Caucasion
345
- </ SelectItem >
346
- < SelectItem value = "Multiple / Other" >
347
- Multiple / Other
348
- </ SelectItem >
349
- < SelectItem value = "Prefer not to say" >
350
- Prefer not to say
351
- </ SelectItem >
362
+ { c . registration . raceOptions . map (
363
+ ( option ) => (
364
+ < SelectItem
365
+ value = { option }
366
+ key = { option }
367
+ >
368
+ { option }
369
+ </ SelectItem >
370
+ ) ,
371
+ ) }
352
372
</ SelectGroup >
353
373
</ SelectContent >
354
374
</ Select >
@@ -360,7 +380,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
360
380
control = { form . control }
361
381
name = "ethnicity"
362
382
render = { ( { field } ) => (
363
- < FormItem className = "col-span-2 " >
383
+ < FormItem className = "" >
364
384
< FormLabel > Ethnicity</ FormLabel >
365
385
< Select
366
386
onValueChange = { field . onChange }
@@ -386,6 +406,103 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
386
406
</ FormItem >
387
407
) }
388
408
/>
409
+ < FormField
410
+ control = { form . control }
411
+ name = "countryOfResidence"
412
+ render = { ( { field } ) => (
413
+ < FormItem className = "grid-cols-2" >
414
+ < FormLabel >
415
+ Country of Residence
416
+ </ FormLabel >
417
+ < div className = "flex w-full items-center justify-center" >
418
+ < Popover >
419
+ < PopoverTrigger asChild >
420
+ < FormControl >
421
+ < Button
422
+ variant = "outline"
423
+ role = "combobox"
424
+ className = { cn (
425
+ "w-full justify-between" ,
426
+ ! field . value &&
427
+ "text-muted-foreground" ,
428
+ ) }
429
+ >
430
+ { field . value
431
+ ? c . registration . countries . find (
432
+ (
433
+ selectedCountry ,
434
+ ) =>
435
+ selectedCountry . code ===
436
+ field . value ,
437
+ ) ?. name
438
+ : "Select a Country" }
439
+ < ChevronsUpDown className = "ml-2 h-4 w-4 shrink-0 opacity-50" />
440
+ </ Button >
441
+ </ FormControl >
442
+ </ PopoverTrigger >
443
+ < PopoverContent className = "no-scrollbar max-h-[400px] w-[250px] overflow-y-auto p-0" >
444
+ < Command >
445
+ < CommandInput placeholder = "Search countries..." />
446
+ < CommandList >
447
+ < CommandEmpty >
448
+ No country
449
+ found.
450
+ </ CommandEmpty >
451
+ < CommandGroup >
452
+ { c . registration . countries . map (
453
+ (
454
+ country ,
455
+ ) => (
456
+ < CommandItem
457
+ value = {
458
+ country . name
459
+ }
460
+ key = {
461
+ country . name
462
+ }
463
+ onSelect = { (
464
+ _ ,
465
+ ) => {
466
+ const countryResult =
467
+ c . registration . countries . find (
468
+ (
469
+ countryObject ,
470
+ ) =>
471
+ countryObject . name ===
472
+ country . name ,
473
+ ) ;
474
+ form . setValue (
475
+ "countryOfResidence" ,
476
+ countryResult ?. code ??
477
+ "00" ,
478
+ ) ;
479
+ } }
480
+ className = "cursor-pointer"
481
+ >
482
+ < Check
483
+ className = { `mr-2 h-4 w-4 ${
484
+ country . name . toLowerCase ( ) ===
485
+ field . value
486
+ ? "block"
487
+ : "hidden"
488
+ } `}
489
+ />
490
+ {
491
+ country . name
492
+ }
493
+ </ CommandItem >
494
+ ) ,
495
+ ) }
496
+ </ CommandGroup >
497
+ </ CommandList >
498
+ </ Command >
499
+ </ PopoverContent >
500
+ </ Popover >
501
+ </ div >
502
+ < FormMessage />
503
+ </ FormItem >
504
+ ) }
505
+ />
389
506
</ div >
390
507
</ FormGroupWrapper >
391
508
< FormGroupWrapper title = "MLH" >
@@ -521,7 +638,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
521
638
) }
522
639
>
523
640
{ field . value
524
- ? schools . find (
641
+ ? c . registration . schools . find (
525
642
( school ) =>
526
643
school ===
527
644
field . value ,
@@ -539,7 +656,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
539
656
No university found.
540
657
</ CommandEmpty >
541
658
< CommandGroup >
542
- { schools . map (
659
+ { c . registration . schools . map (
543
660
( school ) => (
544
661
< CommandItem
545
662
value = {
@@ -598,7 +715,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
598
715
) }
599
716
>
600
717
{ field . value
601
- ? majors . find (
718
+ ? c . registration . majors . find (
602
719
( major ) =>
603
720
major ===
604
721
field . value ,
@@ -616,7 +733,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
616
733
No major found.
617
734
</ CommandEmpty >
618
735
< CommandGroup >
619
- { majors . map (
736
+ { c . registration . majors . map (
620
737
( major ) => (
621
738
< CommandItem
622
739
value = {
@@ -705,7 +822,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
705
822
< FormItem
706
823
className = { `${
707
824
universityValue ===
708
- c . localUniversityName . toLowerCase ( )
825
+ c . localUniversityName
709
826
? "col-span-2 flex flex-col md:col-span-1"
710
827
: "hidden"
711
828
} `}
@@ -889,7 +1006,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
889
1006
event!
890
1007
</ FormDescription >
891
1008
</ div >
892
- { c . dietaryRestrictionOptions . map (
1009
+ { c . registration . dietaryRestrictionOptions . map (
893
1010
( item ) => (
894
1011
< FormField
895
1012
key = { item }
0 commit comments