From 476a3bfb48dbde2808db338153671dde37b6e1eb Mon Sep 17 00:00:00 2001 From: Nick Doan Date: Tue, 16 Apr 2024 13:53:10 -0400 Subject: [PATCH] Collapse row (#165) * Collapse row * Fix test * corrected error messages --------- Co-authored-by: Johnny Tan --- src/app/api/chapter-request/route.schema.ts | 35 ++- src/app/api/chapter-request/route.spec.ts | 2 +- src/app/public/start-chapter/page.tsx | 2 +- src/components/NewChapterForm.tsx | 265 +++++++++++--------- 4 files changed, 170 insertions(+), 134 deletions(-) diff --git a/src/app/api/chapter-request/route.schema.ts b/src/app/api/chapter-request/route.schema.ts index f14a8dde..9c85cae6 100644 --- a/src/app/api/chapter-request/route.schema.ts +++ b/src/app/api/chapter-request/route.schema.ts @@ -14,21 +14,38 @@ import { z } from "zod"; questions String */ export const ChapterRequest = z.object({ - firstName: z.string().min(1, "Please provide a first name"), - lastName: z.string().min(1, "Please provide a last name"), - universityEmail: z.string().email("This is not a valid email"), + firstName: z + .string() + .min(1, "Please provide a first name") + .max(100, "You can provide at most 100 characters"), + lastName: z + .string() + .min(1, "Please provide a last name") + .max(100, "You can provide at most 100 characters"), + universityEmail: z.string().max(100).email("Please provide a valid email"), phoneNumber: z.string().length(10, "Phone number must be 10 digits"), - university: z.string().min(1, "Please provide a university"), - universityAddress: z.string().min(1, "Please provide an address"), + university: z + .string() + .min(1, "Please provide a university") + .max(100, "You can provide at most 100 characters"), + universityAddress: z + .string() + .min(1, "Please provide an address") + .max(100, "You can provide at most 100 characters"), leadershipExperience: z .string() - .min(1, "Please state some leadership experience"), + .min(1, "Please state some leadership experience") + .max(250, "You can provide at most 250 characters"), motivation: z .string() - .min(1, "Please describe your motivation in joining the legacy project"), + .min(1, "Please describe your motivation in joining the Legacy Project") + .max(250, "You can provide at most 250 characters"), // TODO: Figure out if availabilities should have a better type - availabilities: z.string().min(1, "Please provide some times"), - questions: z.string(), + availabilities: z + .string() + .min(1, "Please provide some availability") + .max(100, "You can provide at most 100 characters"), + questions: z.string().max(100, "You can provide at most 100 characters"), }) satisfies z.ZodType; export const ChapterRequestResponse = z.discriminatedUnion("code", [ diff --git a/src/app/api/chapter-request/route.spec.ts b/src/app/api/chapter-request/route.spec.ts index 2eff5c25..7b0fdbf1 100644 --- a/src/app/api/chapter-request/route.spec.ts +++ b/src/app/api/chapter-request/route.spec.ts @@ -16,6 +16,6 @@ describe("ChapterRequest", () => { availabilities: "I am available", questions: "I have a question", }) - ).toThrowError("This is not a valid email"); + ).toThrowError("Please provide a valid email"); }); }); diff --git a/src/app/public/start-chapter/page.tsx b/src/app/public/start-chapter/page.tsx index 679c2658..73102778 100644 --- a/src/app/public/start-chapter/page.tsx +++ b/src/app/public/start-chapter/page.tsx @@ -35,7 +35,7 @@ const StartChapter = () => {

{" "} For additional information, feel free to reach out at{" "} - exec@thelegacyproject.org + exec@thelegacyproject.org.

diff --git a/src/components/NewChapterForm.tsx b/src/components/NewChapterForm.tsx index d92023f4..b8edffd6 100644 --- a/src/components/NewChapterForm.tsx +++ b/src/components/NewChapterForm.tsx @@ -9,6 +9,8 @@ import { ErrorMessage } from "@hookform/error-message"; import { createChapterRequest } from "@api/chapter-request/route.client"; import { useApiThrottle } from "@hooks"; import { Spinner } from "./skeleton"; +import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; +import { faAsterisk } from "@fortawesome/free-solid-svg-icons"; type ValidationSchema = z.infer; @@ -56,167 +58,182 @@ const NewChapterForm = () => {
-
+
First Name
-
- ( -

- {" "} - * - {message} -

- )} - /> -
+ ( +

+ +

{message}

+

+ )} + />
-
+
Last Name
-
- ( -

- * - {message} -

- )} - /> -
+ ( +

+ +

{message}

+

+ )} + />
-
+
University Email
-
- ( -

- * - {message} -

- )} - /> -
+ ( +

+ +

{message}

+

+ )} + />
-
+
Phone Number
-
- ( -

- * - {message} -

- )} - /> -
+ ( +

+ +

{message}

+

+ )} + />
-
+
College / University
-
- ( -

- * - {message} -

- )} - /> -
+ ( +

+ +

{message}

+

+ )} + />
-
+
College / University Address
-
- ( -

- * - {message} -

- )} - /> -
+ ( +

+ +

{message}

+

+ )} + />
-
+
Do you have any experience in student leadership / club - organization / storytelling?{" "} + organization / storytelling?