From a0c42f7e5542e549f2a1ce888e05ab610068274c Mon Sep 17 00:00:00 2001
From: Nareshkumar Rao <_accounts@nareshkumarrao.com>
Date: Thu, 5 Aug 2021 21:57:14 +0200
Subject: [PATCH] toast for loading lockout status
---
src/screens/LockoutScreen.js | 18 ++++++++++++++++--
1 file changed, 16 insertions(+), 2 deletions(-)
diff --git a/src/screens/LockoutScreen.js b/src/screens/LockoutScreen.js
index 73820da..02ce749 100644
--- a/src/screens/LockoutScreen.js
+++ b/src/screens/LockoutScreen.js
@@ -1,4 +1,4 @@
-import { Flex, Heading, Text } from "@chakra-ui/react";
+import { Flex, Heading, Text, useToast } from "@chakra-ui/react";
import axios from "axios";
import { useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
@@ -11,10 +11,17 @@ function Lockout() {
const isCovidPositive = useSelector(state => state.covid.isCovidPositive);
const dispatch = useDispatch();
const history = useHistory();
+ const toast = useToast();
useEffect(() => {
+ toast({
+ title: 'Checking your lockout status...',
+ status: 'info',
+ duration: 10000,
+ });
axios.post(`${process.env.REACT_APP_API_URL}/covid`, {}, { withCredentials: true })
.then(res => {
+ toast.closeAll();
if (res.data.covidPositive) {
dispatch(setCovidPositive());
} else if (res.data.covidPositive === false) {
@@ -26,12 +33,19 @@ function Lockout() {
if (err.response.status === 401) {
dispatch(authLogout());
history.push("/login");
+ }else{
+ toast.closeAll();
+ toast({
+ title: 'Server Error Occurred',
+ status: 'error',
+ duration: 10000,
+ });
}
}
catch (e) { }
});
- }, [dispatch, history]);
+ }, [dispatch, history, toast]);
if (!isAuthenticated) return ;
if (!isCovidPositive) return ;