From 876888b4c8c260c25b92ea2724f5d354b62c2fbf Mon Sep 17 00:00:00 2001 From: chocoboash Date: Tue, 4 Jun 2024 22:32:15 -0400 Subject: [PATCH] Restored last year's landing page system and removed last year's landing pages --- client/src/pages/Initial/LandingPage.jsx | 61 ++++++------------------ 1 file changed, 15 insertions(+), 46 deletions(-) diff --git a/client/src/pages/Initial/LandingPage.jsx b/client/src/pages/Initial/LandingPage.jsx index 886cac9a..6ddff0e1 100644 --- a/client/src/pages/Initial/LandingPage.jsx +++ b/client/src/pages/Initial/LandingPage.jsx @@ -1,78 +1,47 @@ import React, { useEffect, useState } from 'react'; -// F!rosh 2T3 Landing Pages -import { TanuLanding } from './TanuLanding/TanuLanding'; -import { UzmaLanding } from './UzmaLanding/UzmaLanding'; -import { NatLanding } from './NatLanding/NatLanding'; -import { SherryLanding } from './SherryLanding/SherryLanding'; - // F!rosh 2T4 Landing Pages import { AshLanding } from './AshLanding/AshLanding'; -const currentYear = '2T4'; - const landingPages = [ { key: 0, - component: , - year: '2T3', + component: , }, { key: 1, - component: , - year: '2T3', - }, - { - key: 2, - component: , - year: '2T3', - }, - { - key: 3, - component: , - year: '2T3', - }, - { - key: 4, component: , - year: '2T4', }, ]; -// Change this logic to determine which landing pages to show -const landingPagesFiltered = landingPages.filter((page) => page.year === currentYear); - function randomNumber(min, max) { return Math.floor(Math.random() * (max - min + 1) + min); } export const LandingPage = () => { const [pageIndex, setPageIndex] = useState(null); + useEffect(() => { - if (landingPagesFiltered.length !== 1) { - let randIdx = randomNumber(0, landingPagesFiltered.length - 1); - const localIdx = window.localStorage.getItem('landing_page_idx'); + let randIdx = randomNumber(0, landingPages.length - 1); + const localIdx = window.localStorage.getItem('landing_page_idx'); - if (localIdx !== null) { - while (randIdx === JSON.parse(localIdx)) { - randIdx = randomNumber(0, landingPagesFiltered.length - 1); - } + if (localIdx !== null) { + while (randIdx === JSON.parse(localIdx)) { + randIdx = randomNumber(0, landingPages.length - 1); } - window.localStorage.setItem('landing_page_idx', JSON.stringify(randIdx)); - setPageIndex(JSON.parse(randIdx)); } + window.localStorage.setItem('landing_page_idx', JSON.stringify(randIdx)); + + setPageIndex(JSON.parse(randIdx)); }, []); return ( <> - {landingPagesFiltered.length === 1 - ? landingPagesFiltered[0].component - : landingPagesFiltered.map((item) => { - if (item.key === pageIndex) { - return
{item.component}
; - } - return null; - })} + {landingPages.map((item) => { + if (item.key == pageIndex) { + return
{item.component}
; + } + })} ); };