-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added the NavBar to all pages except for /login and /signup
- Loading branch information
1 parent
0d18e06
commit 32b89d4
Showing
3 changed files
with
180 additions
and
88 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
import React, { ReactNode } from 'react'; | ||
import { useLocation } from 'react-router-dom'; | ||
import NavBar from './components/common/navbar/NavBar'; | ||
import PAGE_NAMES from './constants/PageNames'; | ||
|
||
interface LayoutProps { | ||
children: ReactNode; | ||
} | ||
|
||
const Layout: React.FC<LayoutProps> = ({ children }) => { | ||
const location = useLocation(); | ||
|
||
const getPageName = () => { | ||
switch (location.pathname) { | ||
case '/': | ||
return PAGE_NAMES.HOME; | ||
case '/login': | ||
return PAGE_NAMES.LOGIN; | ||
case '/signup': | ||
return PAGE_NAMES.SIGNUP; | ||
case '/edit-team': | ||
return PAGE_NAMES.EDIT_TEAM; | ||
case '/entity': | ||
return PAGE_NAMES.DISPLAY_ENTITY; | ||
case '/entity/create': | ||
return PAGE_NAMES.CREATE_ENTITY; | ||
case '/entity/update': | ||
return PAGE_NAMES.UPDATE_ENTITY; | ||
case '/simpleEntity': | ||
return PAGE_NAMES.DISPLAY_SIMPLE_ENTITY; | ||
case '/simpleEntity/create': | ||
return PAGE_NAMES.CREATE_SIMPLE_ENTITY; | ||
case '/simpleEntity/update': | ||
return PAGE_NAMES.UPDATE_SIMPLE_ENTITY; | ||
case '/hooks': | ||
return PAGE_NAMES.HOOKS; | ||
case '/notifications': | ||
return PAGE_NAMES.NOTIFICATIONS; | ||
case '/profile': | ||
return PAGE_NAMES.PROFILE; | ||
case '/dev-utility': | ||
return PAGE_NAMES.DEV_UTILITY; | ||
case '/admin/users': | ||
return PAGE_NAMES.USER_MANAGEMENT; | ||
case '/admin': | ||
return PAGE_NAMES.ADMIN; | ||
default: | ||
return 'Page'; | ||
} | ||
}; | ||
|
||
return ( | ||
<div> | ||
<NavBar pageName={getPageName()} /> | ||
<main> | ||
{children} | ||
</main> | ||
</div> | ||
); | ||
}; | ||
|
||
export default Layout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
// pageNames.ts | ||
const PAGE_NAMES = { | ||
HOME: 'Home', | ||
LOGIN: 'Login', | ||
SIGNUP: 'Sign Up', | ||
EDIT_TEAM: 'Edit Team', | ||
DISPLAY_ENTITY: 'Entity Details', | ||
CREATE_ENTITY: 'Create Entity', | ||
UPDATE_ENTITY: 'Update Entity', | ||
DISPLAY_SIMPLE_ENTITY: 'Simple Entity Details', | ||
CREATE_SIMPLE_ENTITY: 'Create Simple Entity', | ||
UPDATE_SIMPLE_ENTITY: 'Update Simple Entity', | ||
HOOKS: 'Hooks Demo', | ||
NOTIFICATIONS: 'Notifications', | ||
PROFILE: 'Profile', | ||
DEV_UTILITY: 'Developer Utility', | ||
USER_MANAGEMENT: 'User Management', | ||
ADMIN: 'Admin Dashboard', | ||
// Add additional page names as needed | ||
}; | ||
|
||
export default PAGE_NAMES; |