From 28969a9ae744e8f336fad9832e54d01f01ba145d Mon Sep 17 00:00:00 2001 From: Christian Walker Date: Sun, 11 Aug 2024 21:00:03 -0400 Subject: [PATCH] Fix registration blocking bug --- .../components/registration/RegisterForm.tsx | 25 ++++++++++++------- .../web/src/validators/shared/RegisterForm.ts | 1 + packages/config/hackkit.config.ts | 4 +-- 3 files changed, 19 insertions(+), 11 deletions(-) diff --git a/apps/web/src/components/registration/RegisterForm.tsx b/apps/web/src/components/registration/RegisterForm.tsx index 2c17e657..3432528a 100644 --- a/apps/web/src/components/registration/RegisterForm.tsx +++ b/apps/web/src/components/registration/RegisterForm.tsx @@ -94,12 +94,22 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { }, }); + const { isSubmitSuccessful, isSubmitted, errors} = form.formState; + + const hasErrors = !isSubmitSuccessful && isSubmitted; + + useEffect(() => { + console.log("errors are", errors); + },[errors]); + + const [uploadedFile, setUploadedFile] = useState(null); const [skills, setSkills] = useState([]); const [isLoading, setIsLoading] = useState(false); const universityValue = form.watch("university"); const bioValue = form.watch("bio"); + // wtf is this useEffect(() => { if (universityValue != c.localUniversityName.toLowerCase()) { form.setValue("shortID", "NOT_LOCAL_SCHOOL"); @@ -110,7 +120,6 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { async function onSubmit(data: z.infer) { setIsLoading(true); - console.log("Submision Clicked"); if (!userId || !isLoaded) { setIsLoading(false); return alert( @@ -179,10 +188,6 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { ); } if (acceptedFiles.length > 0) { - console.log( - `Got accepted file! The length of the array is ${acceptedFiles.length}.`, - ); - console.log(acceptedFiles[0]); setUploadedFile(acceptedFiles[0]); } }, @@ -552,10 +557,7 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { onSelect={( value, ) => { - console.log( - "value changed to: ", - value, - ); + form.setValue( "university", value, @@ -1212,6 +1214,11 @@ export default function RegisterForm({ defaultEmail }: RegisterFormProps) { /> + { + hasErrors && ( +

Something doesn't look right. Please check your inputs.

+ ) + } diff --git a/apps/web/src/validators/shared/RegisterForm.ts b/apps/web/src/validators/shared/RegisterForm.ts index d6afb01a..ba46b28f 100644 --- a/apps/web/src/validators/shared/RegisterForm.ts +++ b/apps/web/src/validators/shared/RegisterForm.ts @@ -80,6 +80,7 @@ export const RegisterFormValidator = z.object({ z.literal("Sophomore", defaultPrettyError), z.literal("Junior", defaultPrettyError), z.literal("Senior", defaultPrettyError), + z.literal("Recent Grad", defaultPrettyError), z.literal("Other", defaultPrettyError), ]), hackathonsAttended: z diff --git a/packages/config/hackkit.config.ts b/packages/config/hackkit.config.ts index 3480540d..2301f708 100644 --- a/packages/config/hackkit.config.ts +++ b/packages/config/hackkit.config.ts @@ -592,6 +592,8 @@ export const schools = [ ] as const; export const majors = [ + "Computer Science", + "Cyber Security", "Accounting", "Accounting Technician", "Actuarial Science", @@ -625,13 +627,11 @@ export const majors = [ "Computer & Information Sciences, General", "Computer Engineering", "Computer Networking/Telecommunications", - "Computer Science", "Computer Software & Media Applications", "Computer System Administration", "Construction Engineering/Management", "Creative Writing", "Criminology", - "Cyber Security", "Data Management Technology", "Dental Assisting", "Design & Visual Communications, General",