diff --git a/.gitignore b/.gitignore index cb33574d61..4e25d86efc 100644 --- a/.gitignore +++ b/.gitignore @@ -33,3 +33,6 @@ yarn-error.log* # vercel .vercel + +# others +build.log diff --git a/components/AdBanner/index.js b/components/AdBanner/index.js index 8f9ed84525..17530f9686 100755 --- a/components/AdBanner/index.js +++ b/components/AdBanner/index.js @@ -9,65 +9,41 @@ const BANNERS = [ image: "brave.png", name: "Brave", url: "https://brave.com/wallet/?mtm_campaign=q2&mtm_kwd=chainlist", + isActive: true, }, { image: "llamanodes.png", name: "LlamaNodes", url: "https://llamanodes.com", + isActive: true, + }, + { + image: "gmx.png", + name: "GMX", + url: "https://app.gmx.io/#/trade/?ref=chainlist", + isActive: false, }, - // { - // image: "gmx.png", - // name: "GMX", - // url: "https://app.gmx.io/#/trade/?ref=chainlist", - // }, ]; -const randomBanners = shuffleArray(BANNERS); +const randomBanners = shuffleArray(BANNERS.filter((banner) => banner.isActive)); +const currentIndex = 0 -export const AdBanner = ({ timer = 15000, startTransition = true, showControls = false }) => { +export const AdBanner = () => { const t = useTranslations("Common"); const [isMounted, setIsMounted] = useState(false); - const [currentIndex, setCurrentIndex] = useState(0); - // only render the image client-side to prevent hydration errors due to the random banners useEffect(() => { setIsMounted(true); }, []); - useEffect(() => { - const intervalId = setInterval(() => { - if (startTransition) { - return handleNextBanner(); - } - - return; - }, timer); - - return () => clearInterval(intervalId); - }, [currentIndex]); - - const handlePrevBanner = () => { - const isFirstBanner = currentIndex === 0; - const newIndex = isFirstBanner ? randomBanners.length - 1 : currentIndex - 1; - - setCurrentIndex(newIndex); - }; - - const handleNextBanner = () => { - const isLastBanner = currentIndex === randomBanners.length - 1; - const newIndex = isLastBanner ? 0 : currentIndex + 1; - - setCurrentIndex(newIndex); - }; - const srcLarge = `./banners/large/${randomBanners[currentIndex].image}`; const srcSmall = `./banners/small/${randomBanners[currentIndex].image}`; const srcName = randomBanners[currentIndex].name; return (