diff --git a/components/Banner.tsx b/components/Banner.tsx index a573b5c..8717253 100644 --- a/components/Banner.tsx +++ b/components/Banner.tsx @@ -49,43 +49,44 @@ const Banner = ({ text, link, buttonText }: BannerProps) => { ); }; -const ProductStudioBanner = () => ( - -); +// const ProductStudioBanner = () => ( +// +// ); -const CohortsApplyBanner = () => ( - - Apply by September 15th to be part of - V1's Fall Cohort - - } - link="/apply" - buttonText="Apply now ›" - /> -); +// const CohortsApplyBanner = () => ( +// +// Apply by September 15th to be part of +// V1's Fall Cohort +// +// } +// link="/apply" +// buttonText="Apply now ›" +// /> +// ); -const StartupFairBanner = () => ( - - Apply by October 21st to meet top - startups at V1 Startup Fair - - } - link="https://startupfair.v1michigan.com" - buttonText="Apply now ›" - /> -); +// const StartupFairBanner = () => ( +// +// Apply by October 1st to meet top +// startups at V1 Startup Fair +// +// } +// link="https://startupfair.v1michigan.com" +// buttonText="Apply now ›" +// /> +// ); -export { - Banner as default, - ProductStudioBanner, - CohortsApplyBanner, - StartupFairBanner, -}; +export default Banner; +// export { +// Banner as default, +// ProductStudioBanner, +// CohortsApplyBanner, +// StartupFairBanner, +// }; diff --git a/pages/index.tsx b/pages/index.tsx index 0f3bf5d..1e9e425 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -1,3 +1,4 @@ +import React, { useEffect, useState } from 'react'; import ReactGA from "react-ga4"; import Projects from "../components/Projects"; import NavbarBuilder from "../components/NavBar"; @@ -5,8 +6,13 @@ import Partners from "../components/Partners"; import People, { PeopleChips } from "../components/People"; import Head from "../components/Head"; import GoldButton from "../components/GoldButton"; -import { CohortsApplyBanner } from "../components/Banner"; -// import { StartupFairBanner } from "../components/Banner"; +import Banner from "../components/Banner"; +import { createClient } from "@supabase/supabase-js"; + +const supabaseUrl = process.env.NEXT_PUBLIC_SUPABASE_URL; +const supabaseKey = process.env.NEXT_PUBLIC_SUPABASE_ANON_KEY; + +const supabase = require('@supabase/supabase-js').createClient(supabaseUrl, supabaseKey); const TenX = () => ( <> @@ -18,53 +24,126 @@ const TenX = () => ( ); export default function IndexPage() { + interface BannerData { + id: number; + message: string; + link: string | null; + buttonText: string | null; + } + + const [banners, setBanners] = useState(null); + const [error, setError] = useState([]); + const [toggle, setToggle] = useState(false); + + useEffect(() => { + const fetchBanners = async () => { + let { data: data1, error1 } = await supabase + .from('bannerflags') + .select('*') + .eq('banner_id', '_startupfairPage'); + + if (error1) { + console.error('Error fetching banner flags:', error1); + setError(true) + } else { + console.log('Data:', data1); + let realQuery = data1[0].link; + let { data: data2, error2 } = await supabase + .from('bannerflags') + .select('*') + .eq('banner_id', `${realQuery}`); + if (realQuery == "false") { + setToggle(false); + } + + if (error2) { + console.error('Error fetching banner flags:', error2); + setError(true); + } else { + setBanners(data2 || []); + console.log('Data:', data2); + } + } + }; + + fetchBanners(); + }, []); + return (
- {/* */} - {/* */} + {(error || banners?.length) == 0 && toggle ? ( + + {"Invalid banner ID. Please try again later."} + + } + link={'#'} // Provide a default link if none exists + buttonText={'Learn more'} // Provide a default button text if none exists + open={true} + /> + ) : ( + banners && banners.map((banner) => + banner.message?.length > 0 && ( + + {banner.message} + + } + link={banner.link || '#'} // Provide a default link if none exists + buttonText={banner.buttonText || 'Learn more'} // Provide a default button text if none exists + open={true} + /> + ) + ) + )} +
-
-
-

- V1 builds {/* "things" instead of "projects"? */} - projects. - {/* It's time to build. */} - {/* We invest in smart people who believe they can do big things. */} -

- - ReactGA.event({ - category: "Join us", - action: "Clicked top landing page 'Join us' button", - }) - } - /> -
+
+
+

+ V1 builds {/* "things" instead of "projects"? */} + projects. + {/* It's time to build. */} + {/* We invest in smart people who believe they can do big things. */} +

+ + ReactGA.event({ + category: "Join us", + action: "Clicked top landing page 'Join us' button", + }) + } + />
+
-
-

- V1 is the community for - ambitious student builders — engineers, artists, designers, - founders, scientists, and more. We provide the most driven students - with an extraordinary network, exclusive opportunities within - startups, and mentorship to grow and achieve great things. -

-
+
+

+ V1 is the community for + ambitious student builders — engineers, artists, designers, + founders, scientists, and more. We provide the most driven students + with an extraordinary network, exclusive opportunities within + startups, and mentorship to grow and achieve great things. +

+
-

- What's ? See for yourself. ⚡ -

- +

+ What's ? See for yourself. ⚡ +

+
@@ -72,27 +151,27 @@ export default function IndexPage() {
-

- You're in the right place. -

- - - ReactGA.event({ - category: "Join us", - action: "Clicked bottom landing page 'Join us' button", - }) - } - /> +

+ You're in the right place. +

+ + + ReactGA.event({ + category: "Join us", + action: "Clicked bottom landing page 'Join us' button", + }) + } + />
-

- © 2024 V1 @ Michigan |{" "} - team@v1michigan.com -

+

+ © 2024 V1 @ Michigan |{" "} + team@v1michigan.com +

);