-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat: navbar functionality and visuals (#75)
Co-authored-by: Ryan Chang <[email protected]> Co-authored-by: Amanda Misjuwar <[email protected]>
- Loading branch information
1 parent
9b6972d
commit d2b2ebc
Showing
18 changed files
with
367 additions
and
27 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
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
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,176 @@ | ||
import { | ||
Container, | ||
Flex, | ||
Image, | ||
Button, | ||
Tabs, | ||
Tab, | ||
TabList, | ||
PopoverContent, | ||
PopoverTrigger, | ||
Popover, | ||
PopoverBody, | ||
} from "@chakra-ui/react"; | ||
import { LockIcon, ChevronDownIcon, ChevronUpIcon } from "@chakra-ui/icons"; | ||
|
||
import React, { useContext } from "react"; | ||
import { useHistory } from "react-router-dom"; | ||
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome"; | ||
import { faCampground, faPenToSquare } from "@fortawesome/free-solid-svg-icons"; | ||
|
||
import authAPIClient from "../../APIClients/AuthAPIClient"; | ||
import FONIcon from "../../assets/fon_icon.svg"; | ||
import * as Routes from "../../constants/Routes"; | ||
import AuthContext from "../../contexts/AuthContext"; | ||
import { Role } from "../../types/AuthTypes"; | ||
|
||
import { FontWeights } from "../../theme/textStyles"; | ||
|
||
const NavBar = (): JSX.Element => { | ||
const { authenticatedUser, setAuthenticatedUser } = useContext(AuthContext); | ||
const history = useHistory(); | ||
|
||
const onLogOutClick = async () => { | ||
const success = await authAPIClient.logout(authenticatedUser?.id); | ||
if (success) { | ||
history.push(Routes.LOGIN_PAGE); | ||
setAuthenticatedUser(null); | ||
} | ||
}; | ||
|
||
const navigate = (index: number) => { | ||
switch (index) { | ||
case 0: | ||
history.push(Routes.CAMPS_PAGE); | ||
break; | ||
case 1: | ||
history.push(Routes.GLOBAL_FORMS_PAGE); | ||
break; | ||
case 2: | ||
history.push(Routes.ACCESS_CONTROL_PAGE); | ||
break; | ||
default: | ||
history.push(Routes.CAMPS_PAGE); | ||
break; | ||
} | ||
}; | ||
|
||
const getIndex = () => { | ||
switch (window.location.pathname) { | ||
case Routes.CAMPS_PAGE: | ||
return 0; | ||
case Routes.GLOBAL_FORMS_PAGE: | ||
return 1; | ||
case Routes.ACCESS_CONTROL_PAGE: | ||
return 2; | ||
default: | ||
return 0; | ||
} | ||
}; | ||
|
||
return ( | ||
<Container maxWidth="100vw"> | ||
<Flex | ||
direction="row" | ||
justifyContent="space-between" | ||
marginLeft="80px" | ||
marginRight="80px" | ||
marginTop="14px" | ||
marginBottom="14px" | ||
> | ||
{authenticatedUser ? ( | ||
<> | ||
<Image | ||
src={FONIcon} | ||
alt="FON icon" | ||
display="inline" | ||
width="40px" | ||
height="40px" | ||
/> | ||
<Tabs | ||
variant="unstyled" | ||
onChange={navigate} | ||
defaultIndex={getIndex as any} | ||
width="750px" | ||
alignContent="center" | ||
> | ||
<TabList justifyContent="space-evenly"> | ||
<Tab | ||
id="Camps" | ||
_selected={{ | ||
color: "primary.green.100", | ||
fontWeight: FontWeights.SEMIBOLD, | ||
}} | ||
> | ||
<FontAwesomeIcon icon={faCampground} /> | ||
Camps | ||
</Tab> | ||
{authenticatedUser.role === Role.ADMIN && ( | ||
<> | ||
<Tab | ||
id="Global Forms" | ||
_selected={{ | ||
color: "primary.green.100", | ||
fontWeight: FontWeights.SEMIBOLD, | ||
}} | ||
> | ||
<FontAwesomeIcon icon={faPenToSquare} /> | ||
Global Forms | ||
</Tab> | ||
<Tab | ||
id="Access Control" | ||
_selected={{ | ||
color: "primary.green.100", | ||
fontWeight: FontWeights.SEMIBOLD, | ||
}} | ||
> | ||
<LockIcon /> | ||
Access Control | ||
</Tab> | ||
</> | ||
)} | ||
</TabList> | ||
</Tabs> | ||
<Popover placement="bottom-start" matchWidth> | ||
{({ isOpen }) => ( | ||
<> | ||
<PopoverTrigger> | ||
<Button | ||
rightIcon={ | ||
isOpen ? <ChevronUpIcon /> : <ChevronDownIcon /> | ||
} | ||
bg="background.white.100" | ||
_hover={{ | ||
color: "none", | ||
}} | ||
_active={{ | ||
color: "none", | ||
}} | ||
_focus={{ | ||
color: "none", | ||
}} | ||
> | ||
{authenticatedUser?.firstName}{" "} | ||
{authenticatedUser?.lastName} | ||
</Button> | ||
</PopoverTrigger> | ||
<PopoverContent width="inherit"> | ||
<PopoverBody | ||
as={Button} | ||
bg="background.white.100" | ||
onClick={onLogOutClick} | ||
> | ||
Logout | ||
</PopoverBody> | ||
</PopoverContent> | ||
</> | ||
)} | ||
</Popover> | ||
</> | ||
) : null} | ||
</Flex> | ||
</Container> | ||
); | ||
}; | ||
|
||
export default NavBar; |
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,11 @@ | ||
import React, { useContext } from "react"; | ||
|
||
const AccessControlPage = (): React.ReactElement => { | ||
return ( | ||
<div> | ||
<h2>Access Control Page</h2> | ||
</div> | ||
); | ||
}; | ||
|
||
export default AccessControlPage; |
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,11 @@ | ||
import React, { useContext } from "react"; | ||
|
||
const CampsPage = (): React.ReactElement => { | ||
return ( | ||
<div> | ||
<h2>Camps Page</h2> | ||
</div> | ||
); | ||
}; | ||
|
||
export default CampsPage; |
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,11 @@ | ||
import React, { useContext } from "react"; | ||
|
||
const GlobalFormsPage = (): React.ReactElement => { | ||
return ( | ||
<div> | ||
<h2>Global Forms Page</h2> | ||
</div> | ||
); | ||
}; | ||
|
||
export default GlobalFormsPage; |
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,11 @@ | ||
import React, { useContext } from "react"; | ||
|
||
const LandingPage = (): React.ReactElement => { | ||
return ( | ||
<div> | ||
<h2>Placeholder Landing Page</h2> | ||
</div> | ||
); | ||
}; | ||
|
||
export default LandingPage; |
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
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
enum FontWeights { | ||
export enum FontWeights { | ||
REGULAR = 400, | ||
MEDIUM = 500, | ||
SEMIBOLD = 600, | ||
|
Oops, something went wrong.