diff --git a/webclient/src/InstructorClasses.js b/webclient/src/InstructorClasses.js index c6b3670..6d67495 100644 --- a/webclient/src/InstructorClasses.js +++ b/webclient/src/InstructorClasses.js @@ -202,7 +202,7 @@ export function InstructorClassAttendance(props) { : } @@ -325,6 +325,8 @@ export function InstructorClassList(props) { const [error, setError] = useState(false); const [loading, setLoading] = useState(false); const [success, setSuccess] = useState(false); + const [classes, setClasses] = useState([]); + const [sameClasses, setSameClasses] = useState(false); const handleSubmit = (e) => { if (loading) return; @@ -347,6 +349,22 @@ export function InstructorClassList(props) { }); }; + useEffect(() => { + requester('/sessions/', 'GET', token) + .then(res => { + setClasses(res.results.filter(x => !x.is_cancelled)); + }) + .catch(err => { + console.log(err); + }); + }, []); + + useEffect(() => { + setSameClasses(classes.filter(x => + moment.utc(x.datetime).tz('America/Edmonton').isSame(input.datetime, 'day') + )); + }, [input.datetime]); + return (
Instructor Panel
@@ -354,15 +372,36 @@ export function InstructorClassList(props) { {!open && success &&

Added! View the class.

} {open ? -
-
Add a Class
+ + + +
Add a Class
- + - - Submit - - + + Submit + + +
+ + {!!input.datetime && +
+
Upcoming Classes That Day
+ + {sameClasses.length ? + sameClasses.map(x => +

+ {moment.utc(x.datetime).tz('America/Edmonton').format('LT')} — {x.course_name} +

+ ) + : +

None

+ } +
+ } +
+
: