Browse Source

-Fixed double loading of QR code

- successful acc creation redirects to success screen instead of home screen
- close all toasts upon login
feature/qrscanner
Nareshkumar Rao 3 years ago
parent
commit
23f4fef3b2
  1. 2
      src/screens/CreateScreen.js
  2. 13
      src/screens/HomeScreen.js
  3. 3
      src/screens/LoginScreen.js
  4. 2
      src/screens/SuccessScreen.js

2
src/screens/CreateScreen.js

@ -63,7 +63,7 @@ function Create() {
.then(response => {
if (response.data.success) {
dispatch(authLogin());
history.push('/home');
history.push('/success');
} else {
toast({
title: 'An error occurred',

13
src/screens/HomeScreen.js

@ -1,6 +1,6 @@
import { Flex, Image, Spinner, Text } from '@chakra-ui/react';
import axios from 'axios';
import { React, useState } from 'react';
import { React, useEffect, useState } from 'react';
import { useDispatch, useSelector } from 'react-redux';
import { Redirect } from 'react-router-dom';
import { authLogout } from '../features/auth/authSlice';
@ -9,8 +9,7 @@ function QRCode() {
const [url, setURL] = useState(null);
const dispatch = useDispatch();
if (!url) {
setURL("none");
useEffect(() => {
axios
.get(`${process.env.REACT_APP_API_URL}/code`, { withCredentials: true })
.then(response => {
@ -23,10 +22,12 @@ function QRCode() {
dispatch(authLogout());
}
});
} else if(url === "none"){
return <Spinner/>
}else {
}, [])
if (url) {
return <Image src={url} />;
} else {
return <Spinner />;
}
}

3
src/screens/LoginScreen.js

@ -74,7 +74,8 @@ function Login() {
duration: 9000,
isClosable: true,
});
});
})
.finally(() => { toast.closeAll(); });
e.preventDefault();
};

2
src/screens/SuccessScreen.js

@ -13,7 +13,7 @@ function Success(){
>
<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>
<Text fontSize="lg">We have succesfully saved your contact! Stay safe out there, and let others scan your QR code too!</Text>
<Button onClick={()=>{history.push("/home")}}>Return home</Button>
</Flex>
</Flex>

Loading…
Cancel
Save