From e8aa7372d57b877165f74b4664bfb84e087d2e39 Mon Sep 17 00:00:00 2001
From: Tanner Collin
Date: Mon, 23 May 2022 21:44:09 +0000
Subject: [PATCH] Warn student if class has already ran
---
webclient/src/Classes.js | 27 +++++++++++++++++++++++----
1 file changed, 23 insertions(+), 4 deletions(-)
diff --git a/webclient/src/Classes.js b/webclient/src/Classes.js
index 97dde37..d38b0ba 100644
--- a/webclient/src/Classes.js
+++ b/webclient/src/Classes.js
@@ -472,6 +472,7 @@ export function ClassDetail(props) {
const [refreshCount, refreshClass] = useReducer(x => x + 1, 0);
const [error, setError] = useState(false);
const [loading, setLoading] = useState(false);
+ const [override, setOverride] = useState(false);
const { token, user, refreshUser } = props;
const { id } = useParams();
const userTraining = clazz && clazz.students.find(x => x.user == user.id);
@@ -520,7 +521,8 @@ export function ClassDetail(props) {
setLoading(false);
}, [userTraining]);
- // TODO: calculate yesterday and lock signups
+ const now = new Date().toISOString();
+ const signupDisabled = clazz && clazz.datetime < now && !override;
return (
@@ -631,9 +633,26 @@ export function ClassDetail(props) {
((clazz.max_students && clazz.student_count >= clazz.max_students) ?
The class is full.
:
-
+ <>
+ {clazz.datetime < now &&
+ <>
+ This class has already ran.
+
+
setOverride(v.checked)}
+ />
+
+ >
+ }
+
+
+ >
)
)
)