|
@ -1,6 +1,6 @@ |
|
|
import { Flex, Image, Spinner, Text } from '@chakra-ui/react'; |
|
|
import { Flex, Image, Spinner, Text } from '@chakra-ui/react'; |
|
|
import axios from 'axios'; |
|
|
import axios from 'axios'; |
|
|
import { React, useState } from 'react'; |
|
|
|
|
|
|
|
|
import { React, useEffect, useState } from 'react'; |
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
|
import { useDispatch, useSelector } from 'react-redux'; |
|
|
import { Redirect } from 'react-router-dom'; |
|
|
import { Redirect } from 'react-router-dom'; |
|
|
import { authLogout } from '../features/auth/authSlice'; |
|
|
import { authLogout } from '../features/auth/authSlice'; |
|
@ -9,8 +9,7 @@ function QRCode() { |
|
|
const [url, setURL] = useState(null); |
|
|
const [url, setURL] = useState(null); |
|
|
const dispatch = useDispatch(); |
|
|
const dispatch = useDispatch(); |
|
|
|
|
|
|
|
|
if (!url) { |
|
|
|
|
|
setURL("none"); |
|
|
|
|
|
|
|
|
useEffect(() => { |
|
|
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 => { |
|
@ -23,10 +22,12 @@ function QRCode() { |
|
|
dispatch(authLogout()); |
|
|
dispatch(authLogout()); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
} else if(url === "none"){ |
|
|
|
|
|
return <Spinner/> |
|
|
|
|
|
}else { |
|
|
|
|
|
|
|
|
}, []) |
|
|
|
|
|
|
|
|
|
|
|
if (url) { |
|
|
return <Image src={url} />; |
|
|
return <Image src={url} />; |
|
|
|
|
|
} else { |
|
|
|
|
|
return <Spinner />; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|