From e925a184c3d16ef51f5214540bb1251f6dc7e6eb Mon Sep 17 00:00:00 2001
From: Tanner Collin
Date: Tue, 17 Nov 2020 20:27:12 +0000
Subject: [PATCH] Display alarm status on home page
---
webclient/src/Home.js | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/webclient/src/Home.js b/webclient/src/Home.js
index 0d25fcf..8b6f54b 100644
--- a/webclient/src/Home.js
+++ b/webclient/src/Home.js
@@ -128,7 +128,7 @@ function MemberInfo(props) {
};
export function Home(props) {
- const { user } = props;
+ const { user, token } = props;
const [stats, setStats] = useState(JSON.parse(localStorage.getItem('stats', 'false')));
const [refreshCount, refreshStats] = useReducer(x => x + 1, 0);
const location = useLocation();
@@ -136,7 +136,7 @@ export function Home(props) {
const bypass_code = location.hash.replace('#', '');
useEffect(() => {
- requester('/stats/', 'GET')
+ requester('/stats/', 'GET', token)
.then(res => {
setStats(res);
localStorage.setItem('stats', JSON.stringify(res));
@@ -159,6 +159,8 @@ export function Home(props) {
const getTrackAgo = (x) => stats && stats.track && stats.track[x] ? moment.unix(stats.track[x]['time']).tz('America/Edmonton').fromNow() : '';
const getTrackName = (x) => stats && stats.track && stats.track[x] && stats.track[x]['username'] ? stats.track[x]['username'] : 'Unknown';
+ const alarmStat = () => stats && stats.alarm && moment().unix() - stats.alarm['time'] < 300 ? stats.alarm['data'] > 200 ? 'Armed' : 'Disarmed' : 'Unknown';
+
return (
@@ -273,6 +275,8 @@ export function Home(props) {
} trigger={[more]} />
+
+ {user && user.member.vetted_date && Alarm status: {alarmStat()}
}