-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use AvatarButton dropdown and add b2c dashboard navigation (#163)
* feat: use AvatarButton dropdown and add b2c dashboard navigation * fixes * fix: rename variable
- Loading branch information
1 parent
0e79676
commit fd6ba71
Showing
6 changed files
with
70 additions
and
169 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 was deleted.
Oops, something went wrong.
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,41 @@ | ||
import React, { useContext } from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { NavLink } from 'react-router-dom'; | ||
import { getConfig } from '@edx/frontend-platform/config'; | ||
import { AppContext } from '@edx/frontend-platform/react'; | ||
import { AvatarButton, Dropdown } from '@edx/paragon'; | ||
|
||
const AvatarDropdown = ({ showLabel }) => { | ||
const { BASE_URL, LMS_BASE_URL, LOGOUT_URL } = getConfig(); | ||
const { enterpriseConfig, authenticatedUser } = useContext(AppContext); | ||
const { username, profileImage } = authenticatedUser; | ||
const enterpriseDashboardLink = `/${enterpriseConfig.slug}`; | ||
return ( | ||
<Dropdown> | ||
<Dropdown.Toggle showLabel={showLabel} as={AvatarButton} src={profileImage.imageUrlMedium}> | ||
{username} | ||
</Dropdown.Toggle> | ||
<Dropdown.Menu alignRight> | ||
<Dropdown.Header className="text-uppercase">Switch Dashboard</Dropdown.Header> | ||
<Dropdown.Item href={`${LMS_BASE_URL}/dashboard`}>Personal</Dropdown.Item> | ||
<Dropdown.Item as={NavLink} to={enterpriseDashboardLink}>Enterprise</Dropdown.Item> | ||
<Dropdown.Divider className="border-light" /> | ||
<Dropdown.Item href={`${LMS_BASE_URL}/u/${authenticatedUser.username}`}>My Profile</Dropdown.Item> | ||
<Dropdown.Item href={`${LMS_BASE_URL}/account/settings`}>Account Settings</Dropdown.Item> | ||
<Dropdown.Item href="https://support.edx.org/hc/en-us">Help</Dropdown.Item> | ||
<Dropdown.Divider className="border-light" /> | ||
<Dropdown.Item href={`${LOGOUT_URL}?next=${BASE_URL}${enterpriseDashboardLink}`}>Sign out</Dropdown.Item> | ||
</Dropdown.Menu> | ||
</Dropdown> | ||
); | ||
}; | ||
|
||
AvatarDropdown.propTypes = { | ||
showLabel: PropTypes.bool, | ||
}; | ||
|
||
AvatarDropdown.defaultProps = { | ||
showLabel: true, | ||
}; | ||
|
||
export default AvatarDropdown; |
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