Skip to content

Commit

Permalink
added appPath object to store application path
Browse files Browse the repository at this point in the history
fixing issue DevExpress#8: user menu profile link not working
  • Loading branch information
eric-concept committed Sep 8, 2020
1 parent f628943 commit 4b47278
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 8 deletions.
8 changes: 5 additions & 3 deletions src/app-navigation.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { appPath } from "./app-routes";

export const navigation = [
{
text: 'Home',
path: '/home',
path: appPath.home,
icon: 'home'
},
{
Expand All @@ -10,11 +12,11 @@ export const navigation = [
items: [
{
text: 'Profile',
path: '/profile'
path: appPath.profile
},
{
text: 'Tasks',
path: '/tasks'
path: appPath.tasks
}
]
}
Expand Down
12 changes: 9 additions & 3 deletions src/app-routes.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,23 @@
import { withNavigationWatcher } from './contexts/navigation';
import { HomePage, TasksPage, ProfilePage } from './pages';

export const appPath = {
tasks: '/tasks',
profile: '/profile',
home: '/home,'
}

const routes = [
{
path: '/tasks',
path: appPath.tasks,
component: TasksPage
},
{
path: '/profile',
path: appPath.profile,
component: ProfilePage
},
{
path: '/home',
path: appPath.home,
component: HomePage
}
];
Expand Down
8 changes: 6 additions & 2 deletions src/components/user-panel/user-panel.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,25 @@ import ContextMenu, { Position } from 'devextreme-react/context-menu';
import List from 'devextreme-react/list';
import { useAuth } from '../../contexts/auth';
import './user-panel.scss';
import { useHistory } from 'react-router-dom';
import { appPath } from '../../app-routes';

export default function ({ menuMode }) {
const { user, signOut } = useAuth();
const history = useHistory();

const menuItems = useMemo(() => ([
{
text: 'Profile',
icon: 'user'
icon: 'user',
onClick: () => history.push(appPath.profile)
},
{
text: 'Logout',
icon: 'runner',
onClick: signOut
}
]), [signOut]);
]), [signOut, history]);

return (
<div className={'user-panel'}>
Expand Down

0 comments on commit 4b47278

Please sign in to comment.