summaryrefslogtreecommitdiff
path: root/client/components/home
diff options
context:
space:
mode:
authorJoseph Ditton <jditton.atomic@gmail.com>2021-12-01 20:18:26 -0700
committerJoseph Ditton <jditton.atomic@gmail.com>2021-12-01 20:18:26 -0700
commit84b45cd6b11347e66437cd92dc20372d0abd6eb9 (patch)
tree6e42b5861278485c67159dc57c225983e3fd69f8 /client/components/home
parentd803aaaf1be441f55fe674c3b0c6793e77a9203f (diff)
downloadlocchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.tar.gz
locchat-84b45cd6b11347e66437cd92dc20372d0abd6eb9.zip
adds roles
Diffstat (limited to 'client/components/home')
-rw-r--r--client/components/home/_home.jsx17
1 files changed, 14 insertions, 3 deletions
diff --git a/client/components/home/_home.jsx b/client/components/home/_home.jsx
index 00a7ab3..7ec9335 100644
--- a/client/components/home/_home.jsx
+++ b/client/components/home/_home.jsx
@@ -1,10 +1,16 @@
import { useContext, useEffect, useState } from 'react';
+import { useNavigate } from 'react-router';
import { ApiContext } from '../../utils/api_context';
import { AuthContext } from '../../utils/auth_context';
+import { RolesContext } from '../../utils/roles_context';
+import { Button } from '../common/button';
export const Home = () => {
const [, setAuthToken] = useContext(AuthContext);
const api = useContext(ApiContext);
+ const roles = useContext(RolesContext);
+
+ const navigate = useNavigate();
const [loading, setLoading] = useState(true);
const [user, setUser] = useState(null);
@@ -26,11 +32,16 @@ export const Home = () => {
}
return (
- <div>
+ <div className="p-4">
<h1>Welcome {user.name}</h1>
- <button type="button" onClick={logout}>
+ <Button type="button" onClick={logout}>
Logout
- </button>
+ </Button>
+ {roles.includes('admin') && (
+ <Button type="button" onClick={() => navigate('/admin')}>
+ Admin
+ </Button>
+ )}
</div>
);
};