-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d9fee39
commit 2bcfdb9
Showing
6 changed files
with
152 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,80 @@ | ||
import React from 'react' | ||
import React, {useState, useEffect} from 'react' | ||
import Table from 'react-bootstrap/Table'; | ||
|
||
import "../stylesheets/UpcomingEventsContainer.css"; | ||
|
||
const UpcomingEventsContainer = () => { | ||
const [upcomingEvents, setUpcomingEvents] = useState([]); | ||
|
||
const fetchUpcomingEvents = async () => { | ||
const resp = await fetch("http://localhost:3000/schedule"); | ||
const d = await resp.json(); | ||
console.log("Schedule: ", d); | ||
return d; | ||
}; | ||
|
||
useEffect(() => { | ||
console.log("Upcoming events rendered"); | ||
const fetchData = async () => { | ||
const data = await fetchUpcomingEvents(); | ||
setUpcomingEvents(data); | ||
}; | ||
fetchData(); | ||
}, []); | ||
|
||
useEffect(() => { | ||
console.log("Upcoming events updated: ", upcomingEvents); | ||
},[upcomingEvents]); | ||
|
||
return ( | ||
<> | ||
<div className="upcoming-events-container"> | ||
UpcomingEventsContainer | ||
</div> | ||
<div className="upcoming-events-container d-flex flex-column"> | ||
<h4>Upcoming Events</h4> | ||
{upcomingEvents && upcomingEvents.length > 0 ? ( | ||
<UpcomingEventsTableComponent upcomingEvents={upcomingEvents}/> | ||
) : ( | ||
<p className="text-white">No upcoming events</p> | ||
)} | ||
</div> | ||
</> | ||
) | ||
} | ||
|
||
export default UpcomingEventsContainer | ||
const UpcomingEventsTableComponent = (props) => { | ||
return ( | ||
<> | ||
<div className="d-flex w-100"> | ||
<Table striped bordered hover variant='dark' className="m-3"> | ||
<thead> | ||
<tr> | ||
<th>Event ID</th> | ||
<th>Zone ID</th> | ||
<th>Start Time</th> | ||
<th>Stop Time</th> | ||
<th>Duration (minutes)</th> | ||
<th>Active</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{ | ||
props.upcomingEvents.map((ue, idx) => { | ||
return ( | ||
<tr key={`${ue.zoneID}-${idx}`}> | ||
<td>{ue.eventID}</td> | ||
<td>{ue.zoneID}</td> | ||
<td>{ue.startTime}</td> | ||
<td>{ue.stopTime}</td> | ||
<td>{ue.duration}</td> | ||
<td>{ue.active ? "TRUE" : "FALSE"}</td> | ||
</tr> | ||
) | ||
}) | ||
} | ||
</tbody> | ||
</Table> | ||
</div> | ||
</> | ||
) | ||
}; | ||
|
||
export default UpcomingEventsContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,5 +6,5 @@ | |
height: 100%; | ||
width: 100%; | ||
/* padding: 1em; */ | ||
border: 1px solid blue; | ||
/* border: 1px solid blue; */ | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,5 +4,5 @@ | |
justify-content: center; | ||
width: 100%; | ||
height: 50%; | ||
border: 1px solid red; | ||
border: 1px solid grey; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,5 +5,5 @@ | |
width: 100%; | ||
height: 50%; | ||
/* padding: 1em; */ | ||
border: 1px solid green; | ||
/* border: 1px solid green; */ | ||
} |