From b9e145e24e32e8673ed90cd433eabda61a13637c Mon Sep 17 00:00:00 2001 From: Christian Walker <76548772+christianhelp@users.noreply.github.com> Date: Sat, 10 Aug 2024 01:23:58 -0400 Subject: [PATCH] Fix Registration Form and Uploads (#84) * Fix blob and registration issue * Update admin on dropdown * Update for prettier fixing --- .../components/registration/RegisterForm.tsx | 152 ++++++++++-------- apps/web/src/components/shadcn/ui/command.tsx | 4 +- .../src/components/shared/ProfileButton.tsx | 2 +- 3 files changed, 88 insertions(+), 70 deletions(-) diff --git a/apps/web/src/components/registration/RegisterForm.tsx b/apps/web/src/components/registration/RegisterForm.tsx index 268f4ba7..2c17e657 100644 --- a/apps/web/src/components/registration/RegisterForm.tsx +++ b/apps/web/src/components/registration/RegisterForm.tsx @@ -32,6 +32,7 @@ import { CommandGroup, CommandInput, CommandItem, + CommandList, } from "@/components/shadcn/ui/command"; import { Popover, @@ -58,6 +59,7 @@ interface RegisterFormProps { export default function RegisterForm({ defaultEmail }: RegisterFormProps) { const { isLoaded, userId } = useAuth(); const router = useRouter(); + const form = useForm>({ resolver: zodResolver(RegisterFormValidator), defaultValues: { @@ -95,7 +97,6 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { const [uploadedFile, setUploadedFile] = useState(null); const [skills, setSkills] = useState([]); const [isLoading, setIsLoading] = useState(false); - const universityValue = form.watch("university"); const bioValue = form.watch("bio"); @@ -130,7 +131,8 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { let resume: string = c.noResumeProvidedURL; if (uploadedFile) { - const newBlob = await put(uploadedFile.name, uploadedFile, { + const fileLocation = `${c.hackathonName}/resume/${uploadedFile.name}`; + const newBlob = await put(fileLocation, uploadedFile, { access: "public", handleBlobUploadUrl: "/api/upload/resume/register", }); @@ -522,7 +524,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { {field.value ? schools.find( (school) => - school.toLowerCase() === + school === field.value, ) : "Select a University"} @@ -533,40 +535,48 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { - - No university found. - - - {schools.map( - (school) => ( - { - form.setValue( - "university", + + + No university found. + + + {schools.map( + (school) => ( + - - {school} - - ), - )} - + ) => { + console.log( + "value changed to: ", + value, + ); + form.setValue( + "university", + value, + ); + }} + className="cursor-pointer" + > + + {school} + + ), + )} + + @@ -595,7 +605,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { {field.value ? majors.find( (major) => - major.toLowerCase() === + major === field.value, ) : "Select a Major"} @@ -606,36 +616,44 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { - - No major found. - - - {majors.map((major) => ( - { - form.setValue( - "major", - value, - ); - }} - className="cursor-pointer" - > - - {major} - - ))} - + + + No major found. + + + {majors.map( + (major) => ( + { + form.setValue( + "major", + value, + ); + }} + className="cursor-pointer" + > + + {major} + + ), + )} + + diff --git a/apps/web/src/components/shadcn/ui/command.tsx b/apps/web/src/components/shadcn/ui/command.tsx index 14d0bbea..a3ca5bd1 100644 --- a/apps/web/src/components/shadcn/ui/command.tsx +++ b/apps/web/src/components/shadcn/ui/command.tsx @@ -120,13 +120,13 @@ const CommandItem = React.forwardRef< )); - +// data-[disabled='true']:pointer-events-none data-[disabled='true']:opacity-50 CommandItem.displayName = CommandPrimitive.Item.displayName; const CommandShortcut = ({ diff --git a/apps/web/src/components/shared/ProfileButton.tsx b/apps/web/src/components/shared/ProfileButton.tsx index 0d379fbb..c94f47c7 100644 --- a/apps/web/src/components/shared/ProfileButton.tsx +++ b/apps/web/src/components/shared/ProfileButton.tsx @@ -164,7 +164,7 @@ export default async function ProfileButton() { {user.role === "admin" || (user.role === "super_admin" && ( - + Admin