diff --git a/src/APP/pages/chapter/sections/WelcomeSection.jsx b/src/APP/pages/chapter/sections/WelcomeSection.jsx index ae5515f3..4452625a 100644 --- a/src/APP/pages/chapter/sections/WelcomeSection.jsx +++ b/src/APP/pages/chapter/sections/WelcomeSection.jsx @@ -9,7 +9,7 @@ import usePostJoinChapter from "../../../../hooks/Queries/chapter/usePostJoinCha function WelcomeSection({ chapter }) { const [isOpen, setIsOpen] = useState(false); const [Email, setEmail] = useState(""); - const { + const { setPostEmail: postJoinChapter, error: joinChapterError, clearError: clearJoinChapterError, @@ -23,13 +23,21 @@ function WelcomeSection({ chapter }) { }, []); const validationSchema = Yup.object().shape({ - email: Yup.string().email("Please enter a valid email address.").required("Email address is required."), + email: Yup.string() + .email("Please enter a valid email address.") + .required("Email address is required."), }); - const { register, control, setValue, handleSubmit, formState: { errors }} = useForm({ + const { + register, + control, + setValue, + handleSubmit, + formState: { errors }, + } = useForm({ mode: "onChange", resolver: yupResolver(validationSchema), - }) + }); function closeModal() { setEmail(""); @@ -271,66 +279,88 @@ function WelcomeSection({ chapter }) { leaveTo="opacity-0 scale-95" > - {statusJoinChapter === "success" ? ( <> -
- Successfully joined {chapter.name} {chapter.city} Chapter! Keep an eye on your email for updates on events, offers, and more. -
-
- -
+
+

+ Successfully joined {chapter.name} {chapter.city}{" "} + Chapter! +

+

+ Keep an eye out for email updates on events, offers, + and more. +

+
+
+ +
) : ( <> - - Join {chapter.name} {chapter.city} Chapter - -
- { - setEmail(e.target.value); - joinChapterError && clearJoinChapterError(); - joinChapterError && postJoinChapter(null); - }})} - /> - {errors.email && {errors.email.message}} - {joinChapterError && joinChapterError.non_field_errors ? ( - {joinChapterError.non_field_errors[0]} - ) : ('')} -
- - -
-
- + + Join {chapter.name} {chapter.city} Chapter + +
+ { + setEmail(e.target.value); + joinChapterError && clearJoinChapterError(); + joinChapterError && postJoinChapter(null); + }, + })} + /> + {errors.email && ( + + {errors.email.message} + + )} + {joinChapterError && + joinChapterError.non_field_errors ? ( + + {joinChapterError.non_field_errors[0]} + + ) : ( + "" + )} +
+ + +
+
+ )} -