Skip to content

Commit d8de6c2

Browse files
Feat/registration enhancments (#106)
* updates values to use config * adds phone number and modifies discord * fixes null discord * adds country of residence
1 parent da3ad9d commit d8de6c2

File tree

13 files changed

+3726
-229
lines changed

13 files changed

+3726
-229
lines changed

apps/web/src/app/api/registration/create/route.ts

+2
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,9 @@ export async function POST(req: Request) {
104104
skills: body.skills.map((v) => v.text.toLowerCase()),
105105
profilePhoto: user.imageUrl,
106106
isFullyRegistered: true,
107+
phoneNumber:body.phoneNumber,
107108
isSearchable: body.profileIsSearchable,
109+
countryOfResidence:body.countryOfResidence,
108110
});
109111

110112
await tx.insert(userHackerData).values({

apps/web/src/components/admin/users/ServerSections.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function ProfileInfo({ user }: { user: Hacker }) {
3333
title="Team"
3434
value={user.hackerData.team ? "Yes" : "No"}
3535
/>
36-
<Cell title="Discord" value={user.discord} />
36+
<Cell title="Discord" value={user.discord ?? "N/A"} />
3737
<Cell
3838
title="Linkedin"
3939
value={user.hackerData.LinkedIn || "N/A"}

apps/web/src/components/registration/RegisterForm.tsx

+151-34
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import { zodResolver } from "@hookform/resolvers/zod";
2525
import FormGroupWrapper from "./FormGroupWrapper";
2626
import { Checkbox } from "@/components/shadcn/ui/checkbox";
2727
import Link from "next/link";
28-
import c, { schools, majors } from "config";
28+
import c from "config";
2929
import {
3030
Command,
3131
CommandEmpty,
@@ -52,6 +52,7 @@ import { put, type PutBlobResult } from "@vercel/blob";
5252
import { Tag, TagInput } from "@/components/shadcn/ui/tag/tag-input";
5353
import CreatingRegistration from "./CreatingRegistration";
5454
import { bucketResumeBaseUploadUrl } from "config";
55+
import { count } from "console";
5556
interface RegisterFormProps {
5657
defaultEmail: string;
5758
}
@@ -91,6 +92,8 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
9192
shirtSize: "" as any,
9293
schoolID: "",
9394
university: "",
95+
phoneNumber:"",
96+
countryOfResidence:"",
9497
},
9598
});
9699

@@ -103,16 +106,23 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
103106
const [isLoading, setIsLoading] = useState(false);
104107
const universityValue = form.watch("university");
105108
const bioValue = form.watch("bio");
109+
const countryValue = form.watch("countryOfResidence");
106110

107111
useEffect(() => {
108-
if (universityValue != c.localUniversityName.toLowerCase()) {
112+
if (universityValue != c.localUniversityName) {
109113
form.setValue("schoolID", "NOT_LOCAL_SCHOOL");
110114
} else {
111115
form.setValue("schoolID", "");
112116
}
113117
}, [universityValue]);
114118

119+
120+
useEffect(()=>{
121+
console.log(countryValue)
122+
},[countryValue])
123+
115124
async function onSubmit(data: z.infer<typeof RegisterFormValidator>) {
125+
console.log(data);
116126
setIsLoading(true);
117127
if (!userId || !isLoaded) {
118128
setIsLoading(false);
@@ -168,6 +178,9 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
168178
}
169179
} else {
170180
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+
)
171184
return console.log(
172185
`Recieved a unexpected response from the server. Please try again. If this is a continuing issue, please reach out to us at ${c.issueEmail}.`,
173186
);
@@ -208,7 +221,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
208221
className="space-y-6"
209222
>
210223
<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">
212225
<FormField
213226
control={form.control}
214227
name="firstName"
@@ -217,7 +230,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
217230
<FormLabel>First Name</FormLabel>
218231
<FormControl>
219232
<Input
220-
placeholder="Some"
233+
placeholder="John"
221234
{...field}
222235
/>
223236
</FormControl>
@@ -233,7 +246,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
233246
<FormLabel>Last Name</FormLabel>
234247
<FormControl>
235248
<Input
236-
placeholder="One"
249+
placeholder="Doe"
237250
{...field}
238251
/>
239252
</FormControl>
@@ -259,8 +272,24 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
259272
</FormItem>
260273
)}
261274
/>
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+
/>
262291
</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">
264293
<FormField
265294
control={form.control}
266295
name="age"
@@ -278,7 +307,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
278307
control={form.control}
279308
name="gender"
280309
render={({ field }) => (
281-
<FormItem className="col-span-2">
310+
<FormItem className="">
282311
<FormLabel>Gender</FormLabel>
283312
<Select
284313
onValueChange={field.onChange}
@@ -317,7 +346,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
317346
control={form.control}
318347
name="race"
319348
render={({ field }) => (
320-
<FormItem className="col-span-2">
349+
<FormItem className="">
321350
<FormLabel>Race</FormLabel>
322351
<Select
323352
onValueChange={field.onChange}
@@ -330,25 +359,16 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
330359
</FormControl>
331360
<SelectContent>
332361
<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+
)}
352372
</SelectGroup>
353373
</SelectContent>
354374
</Select>
@@ -360,7 +380,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
360380
control={form.control}
361381
name="ethnicity"
362382
render={({ field }) => (
363-
<FormItem className="col-span-2">
383+
<FormItem className="">
364384
<FormLabel>Ethnicity</FormLabel>
365385
<Select
366386
onValueChange={field.onChange}
@@ -386,6 +406,103 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
386406
</FormItem>
387407
)}
388408
/>
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+
/>
389506
</div>
390507
</FormGroupWrapper>
391508
<FormGroupWrapper title="MLH">
@@ -521,7 +638,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
521638
)}
522639
>
523640
{field.value
524-
? schools.find(
641+
? c.registration.schools.find(
525642
(school) =>
526643
school ===
527644
field.value,
@@ -539,7 +656,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
539656
No university found.
540657
</CommandEmpty>
541658
<CommandGroup>
542-
{schools.map(
659+
{c.registration.schools.map(
543660
(school) => (
544661
<CommandItem
545662
value={
@@ -598,7 +715,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
598715
)}
599716
>
600717
{field.value
601-
? majors.find(
718+
? c.registration.majors.find(
602719
(major) =>
603720
major ===
604721
field.value,
@@ -616,7 +733,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
616733
No major found.
617734
</CommandEmpty>
618735
<CommandGroup>
619-
{majors.map(
736+
{c.registration.majors.map(
620737
(major) => (
621738
<CommandItem
622739
value={
@@ -705,7 +822,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
705822
<FormItem
706823
className={`${
707824
universityValue ===
708-
c.localUniversityName.toLowerCase()
825+
c.localUniversityName
709826
? "col-span-2 flex flex-col md:col-span-1"
710827
: "hidden"
711828
}`}
@@ -889,7 +1006,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) {
8891006
event!
8901007
</FormDescription>
8911008
</div>
892-
{c.dietaryRestrictionOptions.map(
1009+
{c.registration.dietaryRestrictionOptions.map(
8931010
(item) => (
8941011
<FormField
8951012
key={item}

0 commit comments

Comments
 (0)