Skip to content

Commit

Permalink
fix: show register page by setting
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and CarlLiu2023 committed Jul 28, 2023
1 parent db140cd commit 37899d7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 4 deletions.
8 changes: 7 additions & 1 deletion apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ function Registered(props: RegisteredProps) {
const IframeDocument = useSelector(themeFrameSelector)

const {
state: { isCheckout, isCloseGotoBCHome, logo, storeName },
state: { isCheckout, isCloseGotoBCHome, logo, storeName, registerEnabled },
dispatch: globalDispatch,
} = useContext(GlobaledContext)

Expand All @@ -81,6 +81,12 @@ function Registered(props: RegisteredProps) {
},
} = useContext(CustomStyleContext)

useEffect(() => {
if (!registerEnabled) {
navigate('/login')
}
}, [registerEnabled])

useEffect(() => {
const getBCAdditionalFields = async () => {
try {
Expand Down
8 changes: 8 additions & 0 deletions apps/storefront/src/pages/registered/RegisteredBCToB2B.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ export default function RegisteredBCToB2B(props: RegisteredProps) {
logo,
currentChannelId: channelId,
blockPendingAccountOrderCreation,
registerEnabled,
},
dispatch: globalDispatch,
} = useContext(GlobaledContext)
Expand All @@ -117,6 +118,13 @@ export default function RegisteredBCToB2B(props: RegisteredProps) {
})
}

useEffect(() => {
showLoading(false)
if (!registerEnabled) {
navigate('/login')
}
}, [registerEnabled])

useEffect(() => {
const getBCAdditionalFields = async () => {
try {
Expand Down
4 changes: 1 addition & 3 deletions apps/storefront/src/utils/b3AccountItem.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,8 @@ const openPageByClick = ({
role,
isRegisterAndLogin,
}: OpenPageByClickProps) => {
if (role === 100) return '/login'

// register and login click
if (href.includes('/login') || isRegisterAndLogin) {
if (href.includes('/login') || isRegisterAndLogin || role === 100) {
return getCurrentLoginUrl(href)
}

Expand Down

0 comments on commit 37899d7

Please sign in to comment.