diff --git a/client/i18n/locales/english/translations.json b/client/i18n/locales/english/translations.json index 36be08ffa3e..d7cad27a064 100644 --- a/client/i18n/locales/english/translations.json +++ b/client/i18n/locales/english/translations.json @@ -100,7 +100,6 @@ "update-card": "Update your card", "donate-now": "Donate Now", "confirm-amount": "Confirm amount", - "skip-advertisement": "Skip Advertisement", "play-scene": "Press Play" }, "landing": { @@ -645,7 +644,8 @@ "help-millions-learn": "Help millions of people learn", "reach-goals-faster": "Reach your goals faster", "remove-distractions": "Remove distractions", - "animation-description": "This is a 20 second animated advertisement to encourage campers to become supporters of freeCodeCamp. The animation starts with a teddy bear who becomes a supporter. As a result, distracting pop-ups disappear and the bear gets to complete all of its goals. Then, it graduates and becomes an education super hero helping people around the world." + "animation-description": "This is a 20 second animated advertisement to encourage campers to become supporters of freeCodeCamp. The animation starts with a teddy bear who becomes a supporter. As a result, distracting pop-ups disappear and the bear gets to complete all of its goals. Then, it graduates and becomes an education super hero helping people around the world.", + "animation-countdown": "This animation will stop after {{secondsRemaining}} seconds." }, "report": { "sign-in": "You need to be signed in to report a user", diff --git a/client/src/components/Donation/donation-modal-body.tsx b/client/src/components/Donation/donation-modal-body.tsx index 245296fa1c1..6026952747c 100644 --- a/client/src/components/Donation/donation-modal-body.tsx +++ b/client/src/components/Donation/donation-modal-body.tsx @@ -124,16 +124,20 @@ const Benefits = ({ setShowForm }: { setShowForm: (arg: boolean) => void }) => { }; const AnimationContainer = ({ - setIsAnimationVisible + secondsRemaining }: { - setIsAnimationVisible: (arg: boolean) => void; + secondsRemaining: number; }) => { const { t } = useTranslation(); return ( <> -

- {t('donate.animation-description')}{' '} -

+
+

{t('donate.animation-description')}

+ + {t('donate.animation-countdown', { secondsRemaining })} + +
+ - ); }; @@ -226,24 +224,33 @@ function DonationModalBody({ const [showHeaderAndFooter, setShowHeaderAndFooter] = useState(true); const [isAnimationVisible, setIsAnimationVisible] = useState(true); const [showForm, setShowForm] = useState(false); + const [secondsRemaining, setSecondsRemaining] = useState(20); + const handleProcessing = () => { setDonationAttempted(true); }; useEffect(() => { - const timer = setTimeout(() => { - setIsAnimationVisible(false); - }, 20000); // 20000 milliseconds = 20 seconds + const interval = setInterval(() => { + setSecondsRemaining(prevSeconds => { + if (prevSeconds > 0) { + return prevSeconds - 1; + } else { + setIsAnimationVisible(false); + clearInterval(interval); + return 0; + } + }); + }, 1000); - // Clear the timer if the component unmounts - return () => clearTimeout(timer); + return () => clearInterval(interval); }, []); return (
{isAnimationVisible ? ( - + ) : (