From 409d4561c4f7bf8c44cec330e0c2adf58bf8b677 Mon Sep 17 00:00:00 2001
From: Nareshkumar Rao <_accounts@nareshkumarrao.com>
Date: Tue, 27 Jul 2021 00:51:45 +0200
Subject: [PATCH] created verify page
---
src/App.js | 2 ++
src/screens/HomeScreen.js | 2 +-
src/screens/VerifyScreen.js | 55 +++++++++++++++++++++++++++++++++++++
3 files changed, 58 insertions(+), 1 deletion(-)
create mode 100644 src/screens/VerifyScreen.js
diff --git a/src/App.js b/src/App.js
index d408765..2083f8e 100644
--- a/src/App.js
+++ b/src/App.js
@@ -6,6 +6,7 @@ import Login from './screens/LoginScreen';
import Create from './screens/CreateScreen';
import Success from './screens/SuccessScreen';
import './App.css';
+import Verify from './screens/VerifyScreen';
function App() {
return (
@@ -23,6 +24,7 @@ function App() {
+
diff --git a/src/screens/HomeScreen.js b/src/screens/HomeScreen.js
index 53912b2..df420f3 100644
--- a/src/screens/HomeScreen.js
+++ b/src/screens/HomeScreen.js
@@ -22,7 +22,7 @@ function QRCode() {
dispatch(authLogout());
}
});
- }, []);
+ }, [dispatch]);
if (url) {
return ;
diff --git a/src/screens/VerifyScreen.js b/src/screens/VerifyScreen.js
new file mode 100644
index 0000000..199a2de
--- /dev/null
+++ b/src/screens/VerifyScreen.js
@@ -0,0 +1,55 @@
+import { Flex, Text } from '@chakra-ui/react';
+import axios from 'axios';
+import { useEffect, useState } from "react";
+import { useHistory } from "react-router-dom";
+
+function Verify(props) {
+ const verifyID = props.match.params.id;
+ const [verifyError, setVerifyError] = useState(false);
+ const history = useHistory();
+
+ useEffect(() => {
+ if(verifyError) return;
+ axios
+ .post(`${process.env.REACT_APP_API_URL}/verify`,
+ {
+ id: verifyID,
+ },
+ { withCredentials: true },
+ )
+ .then(response => {
+ if (response.data.success) {
+ if (response.data.loggedIn) {
+ history.push("/success");
+ } else {
+ history.push("/create");
+ }
+ }
+ })
+ .catch(err => {
+ setVerifyError(true);
+ });
+ }, [verifyError, history, verifyID]);
+
+ const errorMessage = (
+ An error has occured verifying you. Please try scanning the QR code again?
+ );
+ const loadingMessage = (
+ We are currently verifying you. Please wait.
+ );
+
+ return (
+
+
+ {verifyError ? errorMessage : loadingMessage}
+
+
+ );
+}
+
+export default Verify;
\ No newline at end of file