import "./OurSponsors.css"; import { useEffect, useState } from "react"; import sponsorData from "../MockDB/sponsorship.yml"; import yaml from "js-yaml"; import OpenPage from "../Header/OpenPage"; /** * @param {null} null - requires onthing * @returns {JSX.Element} JSX - HTML tags and JS functionality * @description Our Sponsors Page * @author Brock * @todo finish page layout */ const OurSponsors = () => { const [sponsorsDict, setSponsorsDict] = useState(); //variable states for the dictionary of sponsors useEffect(() => { getSponsors(); }, []); /** * @param {null} null - requires nothing (link) * @returns {Object} sponsorsDict - gets a Dictionary of our sponsors from synology drive * @description Gets the list of sponsors from the synology drive (not implemented), converts the json file into a dictionary * @author Brock * @todo add gPRC to backend and front end add connect to synology drive */ const getSponsors = async () => { const res = await fetch(sponsorData); const rawText = await res.text(); const yamlDict = yaml.load(rawText); try { let res = yamlDict; setSponsorsDict(res); } catch (error) { //error checking console.error("Error recieving data from server:"); } }; if (!sponsorsDict) { //awaiting for a resposne from the backend return

Loading...

; } if (sponsorsDict) { //maps out the dictionary and displays the content return (

Current Sponsors

{/* gets the outmost name of the Object {"Name of tier": {...}} */} {Object.keys(sponsorsDict).map((sponsorTier) => (

{sponsorTier}

{/* gets the keys from the new inner object used so that no two html tags are the "same" */} {Object.keys(sponsorsDict[sponsorTier]).map((sponsorKey) => { const sponsor = sponsorsDict[sponsorTier][sponsorKey]; return (
{sponsor.Name &&

{sponsor.Name}

} {sponsor.LogoUrl && ( { )}
{/* puts this in the sponsor's section only if they are silver and above */} {sponsor.DescriptionAboutSponsor !== undefined && sponsor.DecriptionOnHelp !== undefined && (sponsorTier !== "Bronze Tier" || sponsorTier !== "Silver Tier") && (

Another Element

)}
{/* puts this in the sponsor's section only if they are silver and above */} {sponsor.DescriptionAboutSponsor !== undefined && (sponsorTier !== "Bronze Tier" || sponsorTier !== "Silver Tier") && (

{sponsor.DescriptionAboutSponsor}

)} {/* puts this in the sponsor's section only if they are silver and above */} {sponsor.DecriptionOnHelp !== undefined && (sponsorTier !== "Bronze Tier" || sponsorTier !== "Silver Tier") && (

{sponsor.DecriptionOnHelp}

)}
); })}
))}
); } }; export default OurSponsors;