mirror of
https://github.com/UofCBaja/BajaUofCWebsite.git
synced 2025-06-15 21:34: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 pastSponsorData from "../MockDB/pastSponsors.yml";
|
||||||
import yaml from "js-yaml";
|
import yaml from "js-yaml";
|
||||||
import OpenPage from "../Header/OpenPage";
|
import OpenPage from "../Header/OpenPage";
|
||||||
|
import fakeDelay from "../TestingTools/fakeDelay";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {null} null - requires onthing
|
* @param {null} null - requires onthing
|
||||||
@ -30,9 +31,10 @@ const OurSponsors = () => {
|
|||||||
*/
|
*/
|
||||||
const getCurrentSponsors = async () => {
|
const getCurrentSponsors = async () => {
|
||||||
try {
|
try {
|
||||||
|
await fakeDelay(5000);
|
||||||
const res = await fetch(currentSponsorData);
|
const res = await fetch(currentSponsorData);
|
||||||
const rawText = await res.text();
|
const rawText = await res.text();
|
||||||
const yamlDict = yaml.load(rawText);
|
const yamlDict = await yaml.load(rawText);
|
||||||
setCurrentSponsorsDict(yamlDict);
|
setCurrentSponsorsDict(yamlDict);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
//error checking
|
//error checking
|
||||||
@ -51,21 +53,14 @@ const OurSponsors = () => {
|
|||||||
try {
|
try {
|
||||||
const res = await fetch(pastSponsorData);
|
const res = await fetch(pastSponsorData);
|
||||||
const rawText = await res.text();
|
const rawText = await res.text();
|
||||||
const yamlDict = yaml.load(rawText);
|
const yamlDict = await yaml.load(rawText);
|
||||||
setPastSponsorsDict(yamlDict);
|
setPastSponsorsDict(yamlDict);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// error checking
|
// error checking
|
||||||
console.error("Error recieving data from server:");
|
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 (
|
return (
|
||||||
<div id="OurSponsors">
|
<div id="OurSponsors">
|
||||||
<div id="BecomeASponsors">
|
<div id="BecomeASponsors">
|
||||||
@ -77,6 +72,10 @@ const OurSponsors = () => {
|
|||||||
<div id="Sponsor">
|
<div id="Sponsor">
|
||||||
<h2 className="SponsorsTitle">Current Sponsors</h2>
|
<h2 className="SponsorsTitle">Current Sponsors</h2>
|
||||||
{/* gets the outmost name of the Object Name of tier*/}
|
{/* gets the outmost name of the Object Name of tier*/}
|
||||||
|
{currentSponsorsDict === undefined ? (
|
||||||
|
<p>Loading...</p>
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
{Object.keys(currentSponsorsDict).map((sponsorsTier) => {
|
{Object.keys(currentSponsorsDict).map((sponsorsTier) => {
|
||||||
return (
|
return (
|
||||||
<div className="Sponsors">
|
<div className="Sponsors">
|
||||||
@ -123,12 +122,18 @@ const OurSponsors = () => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
<div id="Sponsor">
|
<div id="Sponsor">
|
||||||
<h2
|
<h2
|
||||||
className="SponsorsTitle"
|
className="SponsorsTitle"
|
||||||
id="SponsorEnd">
|
id="SponsorEnd">
|
||||||
Past Sponsors
|
Past Sponsors
|
||||||
</h2>
|
</h2>
|
||||||
|
{pastSponsorsDict === undefined ? (
|
||||||
|
<p>Loading...</p>
|
||||||
|
) : (
|
||||||
|
<div>
|
||||||
{/* gets keys o objects in list */}
|
{/* gets keys o objects in list */}
|
||||||
{Object.keys(pastSponsorsDict).map((pastSponsorKey) => {
|
{Object.keys(pastSponsorsDict).map((pastSponsorKey) => {
|
||||||
return (
|
return (
|
||||||
@ -158,9 +163,10 @@ const OurSponsors = () => {
|
|||||||
);
|
);
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
)}
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
);
|
);
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export default OurSponsors;
|
export default OurSponsors;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user