mirror of
https://github.com/UofCBaja/BajaUofCWebsite.git
synced 2025-06-15 13:24:17 -06:00
changed if statements to ? : statements
This commit is contained in:
parent
585138e772
commit
98ee3152c9
@ -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,21 +53,14 @@ 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 <p>Loading...</p>;
|
||||
}
|
||||
if (currentSponsorsDict && pastSponsorsDict) {
|
||||
//maps out the dictionary and displays the content
|
||||
|
||||
return (
|
||||
<div id="OurSponsors">
|
||||
<div id="BecomeASponsors">
|
||||
@ -77,6 +72,10 @@ const OurSponsors = () => {
|
||||
<div id="Sponsor">
|
||||
<h2 className="SponsorsTitle">Current Sponsors</h2>
|
||||
{/* gets the outmost name of the Object Name of tier*/}
|
||||
{currentSponsorsDict === undefined ? (
|
||||
<p>Loading...</p>
|
||||
) : (
|
||||
<div>
|
||||
{Object.keys(currentSponsorsDict).map((sponsorsTier) => {
|
||||
return (
|
||||
<div className="Sponsors">
|
||||
@ -123,12 +122,18 @@ const OurSponsors = () => {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
<div id="Sponsor">
|
||||
<h2
|
||||
className="SponsorsTitle"
|
||||
id="SponsorEnd">
|
||||
Past Sponsors
|
||||
</h2>
|
||||
{pastSponsorsDict === undefined ? (
|
||||
<p>Loading...</p>
|
||||
) : (
|
||||
<div>
|
||||
{/* gets keys o objects in list */}
|
||||
{Object.keys(pastSponsorsDict).map((pastSponsorKey) => {
|
||||
return (
|
||||
@ -158,9 +163,10 @@ const OurSponsors = () => {
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
};
|
||||
|
||||
export default OurSponsors;
|
||||
|
Loading…
x
Reference in New Issue
Block a user