From 2936a3a82683be2dc4da17262554bda28502388d Mon Sep 17 00:00:00 2001 From: jasquat Date: Wed, 2 Nov 2022 16:02:43 -0400 Subject: [PATCH] added login_logout buttons w/ burnettk --- .../src/components/NavigationBar.tsx | 77 ++++++++----------- 1 file changed, 31 insertions(+), 46 deletions(-) diff --git a/spiffworkflow-frontend/src/components/NavigationBar.tsx b/spiffworkflow-frontend/src/components/NavigationBar.tsx index 863d4f26..cb3b5271 100644 --- a/spiffworkflow-frontend/src/components/NavigationBar.tsx +++ b/spiffworkflow-frontend/src/components/NavigationBar.tsx @@ -1,12 +1,17 @@ import { Header, Theme, + Button, HeaderName, HeaderNavigation, HeaderMenuItem, HeaderMenu, + HeaderGlobalAction, + HeaderGlobalBar, // @ts-ignore } from '@carbon/react'; +// @ts-ignore +import { Logout, Login } from '@carbon/icons-react'; import { useEffect, useState } from 'react'; import { useLocation } from 'react-router-dom'; // @ts-expect-error TS(2307) FIXME: Cannot find module '../logo.svg' or its correspond... Remove this comment to see the full error message @@ -15,52 +20,13 @@ import UserService from '../services/UserService'; // for ref: https://react-bootstrap.github.io/components/navbar/ export default function NavigationBar() { - // const navElements = null; - // - // const handleLogout = () => { - // UserService.doLogout(); - // }; - // - // const handleLogin = () => { - // UserService.doLogin(); - // }; - // - // const loginLink = () => { - // if (!UserService.isLoggedIn()) { - // return ( - // - // - // - // - // - // ); - // } - // return null; - // }; - // - // const logoutLink = () => { - // if (UserService.isLoggedIn()) { - // return ( - // - // - // Signed in as: {UserService.getUsername()} - // - // - // - // - // - // ); - // } - // return null; - // }; + const handleLogout = () => { + UserService.doLogout(); + }; + + const handleLogin = () => { + UserService.doLogin(); + }; const location = useLocation(); const [activeKey, setActiveKey] = useState(''); @@ -87,6 +53,24 @@ export default function NavigationBar() { return activeKey === menuItemPath; }; + const loginAndLogoutAction = () => { + if (UserService.isLoggedIn()) { + return ( + <> + {UserService.getUsername()} + + + + + ); + } + return ( + + + + ); + }; + if (activeKey) { return (
@@ -112,6 +96,7 @@ export default function NavigationBar() { Process Instances + {loginAndLogoutAction()}