diff --git a/components/UI/Button/Button.js b/components/UI/Button/Button.js index 64151cf8..1cace2fd 100644 --- a/components/UI/Button/Button.js +++ b/components/UI/Button/Button.js @@ -1,4 +1,4 @@ -import React, { useState } from "react"; +import React, { useEffect, useState } from "react"; import styles from "./Button.module.css"; function Button({ @@ -8,9 +8,12 @@ function Button({ className, type = "button", onClick, + loading=false }) { - const [isLoading, setIsLoading] = useState(false); + const [isLoading, setIsLoading] = useState(loading); let variantClass = `btn${variant.charAt(0).toUpperCase()}${variant.slice(1)}`; + + useEffect(()=>{setIsLoading(loading)}, [loading]) return isLoading ? (
{ const [email, setEmail] = useState(""); const [subscriptionSuccess, setSubscriptionSuccess] = useState(false); + useEffect(()=>{}, [isLoading]); + const handleSubmit = (e) => { e.preventDefault(); setIsLoading(true); @@ -58,6 +60,7 @@ const ComingSoon = () => { LeftIcon={MdKeyboardArrowLeft} text="back" className="tw-flex tw-items-center" + loading={true} /> {/* header and form section */} @@ -97,6 +100,7 @@ const ComingSoon = () => { type="submit" onClick={handleSubmit} className="tw-w-full tw-mt-4 sm:tw-mt-0 sm:tw-w-fit" + loading={isLoading} /> )} diff --git a/components/layout/Footer.js b/components/layout/Footer.js index a7be358a..a028afd0 100644 --- a/components/layout/Footer.js +++ b/components/layout/Footer.js @@ -13,25 +13,29 @@ import FooterColumn from "./FooterColumn"; import { FaCheckCircle } from "react-icons/fa"; function Footer() { + + const [email, setEmail] = useState(""); + const [subscriptionSuccess, setSubscriptionSuccess] = useState(false); + const [isLoading, setIsLoading] = useState(false); + const currentYear = new Date().getFullYear(); + const handleSubmit = (e) => { e.preventDefault(); - + setIsLoading(true); axios .post(`${process.env.NEXT_PUBLIC_BACKEND_URL}/api/newsletter/subscribe`, { email, }) .then((response) => { - console.log(response.data); + setIsLoading(false); setSubscriptionSuccess(true); }) .catch((error) => { + setIsLoading(false); console.error(error); }); }; - const [email, setEmail] = useState(""); - const [subscriptionSuccess, setSubscriptionSuccess] = useState(false); - const currentYear = new Date().getFullYear(); return (
diff --git a/components/mentorDashboard/home.js b/components/mentorDashboard/home.js index df0bb5e7..7a2111fc 100644 --- a/components/mentorDashboard/home.js +++ b/components/mentorDashboard/home.js @@ -275,7 +275,7 @@ const Home = ({ )} {card.session && (
- {card.session.length > 0 ? ( + {card?.session?.type ? (

Title:{" "} @@ -283,7 +283,7 @@ const Home = ({ {card.session.title}

-
+

{card.session.type}