Skip to content

Commit

Permalink
fix: junior can not access account pages
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Jan 2, 2024
1 parent 884c8bb commit 06d5507
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 3 deletions.
15 changes: 13 additions & 2 deletions apps/storefront/src/utils/b3AccountItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,15 +68,15 @@ const redirectBcMenus = (
: '/dashboard'
}

if (+role === 2 && currentItem?.newTargetUrl.includes('order_status')) {
if (+role === 2 && currentItem?.newTargetUrl?.includes('order_status')) {
return '/accountSettings'
}

if (currentItem?.newTargetUrl) {
return currentItem.newTargetUrl
}

return '/orders'
return +role === 2 ? '/accountSettings' : '/orders'
}

const getCurrentLoginUrl = (href: string): string => {
Expand All @@ -101,6 +101,17 @@ const openPageByClick = ({
if (href?.includes('/orders')) {
return role !== 100 ? '/orders' : '/login'
}

if (
+role === 2 &&
(href?.includes('/orders') ||
href?.includes('/accountSettings') ||
href?.includes('/login') ||
href?.includes('/account')) &&
!href?.includes('logout')
) {
return '/accountSettings'
}
// register and login click
if (href?.includes('/login') || isRegisterAndLogin || role === 100) {
return getCurrentLoginUrl(href)
Expand Down
1 change: 1 addition & 0 deletions packages/global-b3/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ const themeOtherElementConfig = () => {
'.navUser-item--more, #navUser-more-toggle, #navUser-more-toggle .navUser-item-icon, #navUser-more-toggle .navUser-item-icon svg, #navUser-more-toggle .navUser-item-icon svg use, #navUser-more-toggle .navUser-item-moreLabel, .header-top-item--login, .header-top-item--login .header-top-action, .header-top-item--logout, .header-top-item--logout [href^="/login.php?action=logout"]',
HaloOne:
'[href^="/account.php"] svg, [href^="/account.php"] svg path, [href="/login.php"] svg path',
FinchUS: '[href^="/account.php"] img',
}

if (window?.B3CustomConfig) {
Expand Down
3 changes: 2 additions & 1 deletion packages/hooks/useB3AppOpen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,9 @@ export const useB3AppOpen = (initOpenState: OpenPageState) => {
!href.includes('action=create_account') &&
!href.includes('action=logout')
) {
href = '/orders'
href = +B3Role === 2 ? '/accountSettings' : '/orders'
}

if (initOpenState?.handleEnterClick) {
initOpenState.handleEnterClick(
href,
Expand Down

0 comments on commit 06d5507

Please sign in to comment.