Browse Source

added success screen

feature/qrscanner
Nareshkumar Rao 3 years ago
parent
commit
6f96a68ff8
  1. 9
      src/App.css
  2. 5
      src/App.js
  3. 2
      src/screens/CreateScreen.js
  4. 15
      src/screens/HomeScreen.js
  5. 15
      src/screens/LoginScreen.js
  6. 23
      src/screens/SuccessScreen.js

9
src/App.css

@ -0,0 +1,9 @@
#QRFlex{
width: 30%;
}
@media only screen and (max-width: 600px) {
#QRFlex {
width: 90% ;
}
}

5
src/App.js

@ -4,6 +4,8 @@ import { Redirect, Route, Switch } from 'react-router-dom';
import Home from './screens/HomeScreen'; import Home from './screens/HomeScreen';
import Login from './screens/LoginScreen'; import Login from './screens/LoginScreen';
import Create from './screens/CreateScreen'; import Create from './screens/CreateScreen';
import Success from './screens/SuccessScreen';
import './App.css';
function App() { function App() {
return ( return (
@ -18,6 +20,9 @@ function App() {
<Route path="/create"> <Route path="/create">
<Create /> <Create />
</Route> </Route>
<Route path="/success">
<Success />
</Route>
<Route path="/"> <Route path="/">
<Redirect to="/home" /> <Redirect to="/home" />
</Route> </Route>

2
src/screens/CreateScreen.js

@ -1,4 +1,4 @@
import { FormControl, Box, Flex, Image, FormLabel, Input, Select, Heading, Button, useToast } from '@chakra-ui/react';
import { Button, Flex, FormControl, FormLabel, Heading, Input, Select, useToast } from '@chakra-ui/react';
import axios from 'axios'; import axios from 'axios';
import { useState } from 'react'; import { useState } from 'react';
import { useDispatch } from 'react-redux'; import { useDispatch } from 'react-redux';

15
src/screens/HomeScreen.js

@ -1,4 +1,4 @@
import { Box, Flex, Image } from '@chakra-ui/react';
import { Box, Center, Flex, Image, Spinner, Text } from '@chakra-ui/react';
import axios from 'axios'; import axios from 'axios';
import { React, useState } from 'react'; import { React, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux'; import { useDispatch, useSelector } from 'react-redux';
@ -10,6 +10,7 @@ function QRCode() {
const dispatch = useDispatch(); const dispatch = useDispatch();
if (!url) { if (!url) {
setURL("none");
axios axios
.get(`${process.env.REACT_APP_API_URL}/code`, { withCredentials: true }) .get(`${process.env.REACT_APP_API_URL}/code`, { withCredentials: true })
.then(response => { .then(response => {
@ -22,13 +23,12 @@ function QRCode() {
dispatch(authLogout()); dispatch(authLogout());
} }
}); });
}
if (url) {
return <Image src={url} />;
} else if(url === "none"){
return <Spinner/>
}else { }else {
return <Box />;
return <Image src={url} />;
} }
} }
function Home() { function Home() {
@ -42,8 +42,9 @@ function Home() {
alignItems="center" alignItems="center"
justifyContent="center" justifyContent="center"
> >
<Flex direction="column" background="white" p={12} rounded={6}>
<Flex direction="column" background="white" p={12} rounded={6} id="QRFlex">
<QRCode /> <QRCode />
<Text align="center" fontSize="lg">This is your QR code. Show this to others to allow them to confirm a contact, or allow them to create an account!</Text>
</Flex> </Flex>
</Flex> </Flex>
); );

15
src/screens/LoginScreen.js

@ -36,6 +36,13 @@ function Login() {
return; return;
} }
toast({
title: 'Loading',
status: 'info',
duration: 9000,
isClosable: true,
});
axios axios
.post( .post(
`${process.env.REACT_APP_API_URL}/login`, `${process.env.REACT_APP_API_URL}/login`,
@ -109,14 +116,6 @@ function Login() {
Login! Login!
</Button> </Button>
</form> </form>
<Divider mb={6} />
<Button
onClick={() => {
history.push('/validate');
}}
>
Get Validated!
</Button>
</Flex> </Flex>
</Flex> </Flex>
); );

23
src/screens/SuccessScreen.js

@ -0,0 +1,23 @@
import { Button, Flex, Heading, Text } from "@chakra-ui/react";
import { useHistory } from "react-router-dom";
function Success(){
const history = useHistory();
return (
<Flex
height="100vh"
background="teal.100"
alignItems="center"
justifyContent="center"
>
<Flex direction="column" background="white" p={12} rounded={6}>
<Heading>Success!</Heading>
<Text fontSize="lg">We have succesfully saved your contact! Stay safe out there!</Text>
<Button onClick={()=>{history.push("/home")}}>Return home</Button>
</Flex>
</Flex>
);
}
export default Success;
Loading…
Cancel
Save