From 98ee3152c94d84ea64fd398f52df294c95606439 Mon Sep 17 00:00:00 2001 From: darkicewolf50 Date: Sun, 17 Mar 2024 12:16:12 -0600 Subject: [PATCH] changed if statements to ? : statements --- src/OurSponsors/OurSponsors.js | 214 +++++++++++++++++---------------- 1 file changed, 110 insertions(+), 104 deletions(-) diff --git a/src/OurSponsors/OurSponsors.js b/src/OurSponsors/OurSponsors.js index dc42482..3c33305 100644 --- a/src/OurSponsors/OurSponsors.js +++ b/src/OurSponsors/OurSponsors.js @@ -4,6 +4,7 @@ import currentSponsorData from "../MockDB/sponsorship.yml"; import pastSponsorData from "../MockDB/pastSponsors.yml"; import yaml from "js-yaml"; import OpenPage from "../Header/OpenPage"; +import fakeDelay from "../TestingTools/fakeDelay"; /** * @param {null} null - requires onthing @@ -30,9 +31,10 @@ const OurSponsors = () => { */ const getCurrentSponsors = async () => { try { + await fakeDelay(5000); const res = await fetch(currentSponsorData); const rawText = await res.text(); - const yamlDict = yaml.load(rawText); + const yamlDict = await yaml.load(rawText); setCurrentSponsorsDict(yamlDict); } catch (error) { //error checking @@ -51,116 +53,120 @@ const OurSponsors = () => { try { const res = await fetch(pastSponsorData); const rawText = await res.text(); - const yamlDict = yaml.load(rawText); + const yamlDict = await yaml.load(rawText); setPastSponsorsDict(yamlDict); } catch (error) { // error checking console.error("Error recieving data from server:"); } }; - // needs to change into ? : statement and have content above it - if (!currentSponsorsDict && !pastSponsorsDict) { - //awaiting for a resposne from the backend - //add loading notification to user - return

Loading...

; - } - if (currentSponsorsDict && pastSponsorsDict) { - //maps out the dictionary and displays the content - return ( -
-
- -
- - + + return ( +
+
+
- ); - } + + +
+ ); }; export default OurSponsors;