Skip to content

Commit

Permalink
fix: fix msfStore error
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 committed Aug 16, 2023
1 parent c3fac6a commit 5993935
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
3 changes: 2 additions & 1 deletion apps/storefront/src/components/B3StoreContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ export function B3StoreContainer(props: B3StoreContainerProps) {
const { storeBasicInfo }: CustomFieldItems = await getBCStoreChannelId()

const storeInfo = getCurrentStoreInfo(
(storeBasicInfo as StoreBasicInfo)?.storeSites || []
(storeBasicInfo as StoreBasicInfo)?.storeSites || [],
storeBasicInfo.multiStorefrontEnabled
)

if (!storeInfo?.channelId) return
Expand Down
16 changes: 15 additions & 1 deletion apps/storefront/src/utils/loginInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ export interface ChannelStoreSites {
}

export const getCurrentStoreInfo = (
storeSites: Array<ChannelIdProps>
storeSites: Array<ChannelIdProps>,
multiStorefrontEnabled: boolean
): Partial<ChannelIdProps> => {
const newStoreSites =
storeSites.filter((site: ChannelIdProps) => !!site.isEnabled) || []
Expand All @@ -63,6 +64,19 @@ export const getCurrentStoreInfo = (
}
}

if (!multiStorefrontEnabled) {
store = {
channelId: 1,
urls: [],
b2bEnabled: true,
channelLogo: '',
b3ChannelId: 1,
type: 'storefront',
platform: 'bigcommerce',
isEnabled: true,
}
}

const { origin } = window.location
const storeItem =
newStoreSites.find((item: ChannelIdProps) => item.urls.includes(origin)) ||
Expand Down

0 comments on commit 5993935

Please sign in to comment.