Nareshkumar Rao
3 years ago
committed by
GitHub
8 changed files with 160 additions and 82 deletions
@ -1,2 +1,4 @@ |
|||
REACT_APP_API_URL= |
|||
REACT_APP_TELEGRAM_BOT_NAME= |
|||
REACT_APP_TELEGRAM_BOT_NAME= |
|||
|
|||
# REACT_APP_DONATE_LINK= |
@ -1,9 +1,20 @@ |
|||
:root { |
|||
background: var(--chakra-colors-teal-100); |
|||
} |
|||
|
|||
#QRFlex { |
|||
width: 30%; |
|||
} |
|||
|
|||
@media only screen and (max-width: 600px) { |
|||
#contentFlex { |
|||
width: 30%; |
|||
} |
|||
|
|||
@media only screen and (max-width: 800px) { |
|||
#QRFlex { |
|||
width: 90%; |
|||
} |
|||
#contentFlex { |
|||
width: 90%; |
|||
} |
|||
} |
|||
|
@ -1,55 +1,58 @@ |
|||
import { Flex, Text } from '@chakra-ui/react'; |
|||
import axios from 'axios'; |
|||
import { useEffect, useState } from "react"; |
|||
import { useHistory } from "react-router-dom"; |
|||
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(); |
|||
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("/login"); |
|||
} |
|||
} |
|||
}) |
|||
.catch(err => { |
|||
setVerifyError(true); |
|||
}); |
|||
}, [verifyError, history, verifyID]); |
|||
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('/login'); |
|||
} |
|||
} |
|||
}) |
|||
.catch(err => { |
|||
setVerifyError(true); |
|||
}); |
|||
}, [verifyError, history, verifyID]); |
|||
|
|||
const errorMessage = ( |
|||
<Text>An error has occured verifying you. Please try scanning the QR code again?</Text> |
|||
); |
|||
const loadingMessage = ( |
|||
<Text>We are currently verifying you. Please wait.</Text> |
|||
); |
|||
const errorMessage = ( |
|||
<Text> |
|||
An error has occured verifying you. Please try scanning the QR code again? |
|||
</Text> |
|||
); |
|||
const loadingMessage = ( |
|||
<Text>We are currently verifying you. Please wait.</Text> |
|||
); |
|||
|
|||
return ( |
|||
<Flex |
|||
height="100vh" |
|||
background="teal.100" |
|||
alignItems="center" |
|||
justifyContent="center" |
|||
> |
|||
<Flex direction="column" background="white" p={12} rounded={6}> |
|||
{verifyError ? errorMessage : loadingMessage} |
|||
</Flex> |
|||
</Flex> |
|||
); |
|||
return ( |
|||
<Flex |
|||
height="100vh" |
|||
background="teal.100" |
|||
alignItems="center" |
|||
justifyContent="center" |
|||
> |
|||
<Flex direction="column" background="white" p={12} rounded={6}> |
|||
{verifyError ? errorMessage : loadingMessage} |
|||
</Flex> |
|||
</Flex> |
|||
); |
|||
} |
|||
|
|||
export default Verify; |
|||
export default Verify; |
|||
|
Loading…
Reference in new issue