From 84b45cd6b11347e66437cd92dc20372d0abd6eb9 Mon Sep 17 00:00:00 2001
From: Joseph Ditton <jditton.atomic@gmail.com>
Date: Wed, 1 Dec 2021 20:18:26 -0700
Subject: adds roles

---
 client/components/home/_home.jsx | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)

(limited to 'client/components/home/_home.jsx')

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>
   );
 };
-- 
cgit v1.2.3-70-g09d2

