Browse Source

added logout button

pull/4/head
Nareshkumar Rao 3 years ago
parent
commit
c36c4ef052
  1. 10
      src/screens/HomeScreen.js

10
src/screens/HomeScreen.js

@ -35,6 +35,12 @@ function QRCode() {
function Home() { function Home() {
const history = useHistory(); const history = useHistory();
const dispatch = useDispatch();
const handleLogout = () => {
dispatch(authLogout());
history.push("/login");
}
const isAuthenticated = useSelector(state => state.auth.isAuthenticated); const isAuthenticated = useSelector(state => state.auth.isAuthenticated);
if (!isAuthenticated) return <Redirect to="/login" />; if (!isAuthenticated) return <Redirect to="/login" />;
@ -59,7 +65,9 @@ function Home() {
contact, or allow them to create an account! contact, or allow them to create an account!
</Text> </Text>
<Divider mb={6} /> <Divider mb={6} />
<Button onClick={()=>{history.push("/scanner");}}>Scan a QR Code</Button>
<Button mb={6} onClick={()=>{history.push("/scanner");}}>Scan a QR Code</Button>
<Divider mb={10} />
<Button mb={6} onClick={handleLogout}>Log Out!</Button>
</Flex> </Flex>
</Flex> </Flex>
); );

Loading…
Cancel
Save