Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Work in initiatives bug
Browse files Browse the repository at this point in the history
Co-authored-by: Elias Xu <[email protected]>
Co-authored-by: Connor Yau <[email protected]>
  • Loading branch information
Elias2660 and connor132435 committed Feb 4, 2024
1 parent d92842d commit c007b89
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
1 change: 1 addition & 0 deletions src/components/NonPage/Initiatives.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ body {
flex-wrap: wrap;
row-gap: 100px;
column-gap: 20px;
min-height: 50vh;
}

.frame .event {
Expand Down
12 changes: 7 additions & 5 deletions src/components/NonPage/Initiatives.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export default function AllInitiatives(props) {
const sheet_name = "Announcements";
const response = await fetch(`https://docs.google.com/spreadsheets/d/${ID}/gviz/tq?tqx=out:csv&sheet=${sheet_name}`);
const text = await response.text();
const parsedData = Papa.parse(text, { header: true }).data;
const parsedData = Papa.parse(text, { header: true }).data.reverse();
setEventsInfo(parsedData);
setShowMore(Array(parsedData.length).fill(false));
} catch (err) {
Expand All @@ -34,16 +34,18 @@ export default function AllInitiatives(props) {
return (
<div className="all-initiatives">
<div className="frame">
{initiativesData.reverse().map((initiative, index) => (
{initiativesData.map((initiative, index) => (
<div className="event" key={index}>
<p className="event-date">{initiative.Date}</p>
<h4 className="event-title">{initiative.Title}</h4>
<p className="event-text">
{showMore[index] ? initiative.Text : initiative.Text.substring(0, 100)}
</p>
<button className="show-more" onClick={() => handleShowMoreToggle(index)}>
{showMore[index] ? "Show Less" : "Show More..."}
</button>
{showMore[index] ?
<button className="show-more" onClick={() => handleShowMoreToggle(index)}>
{showMore[index] ? "Show Less" : "Show More..."}
</button> : null
}
</div>
))}
</div>
Expand Down

0 comments on commit c007b89

Please sign in to comment.