Skip to content

Commit

Permalink
Brian/fix/ignore headless url (#319)
Browse files Browse the repository at this point in the history
* fix: ignore headless url
  • Loading branch information
BrianJiang2021 committed Apr 26, 2023
1 parent 0c58a7a commit 6e083fa
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 11 deletions.
2 changes: 2 additions & 0 deletions apps/storefront/src/components/B3StoreContainer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ interface StoreItem {
channelLogo: string
isEnabled: boolean
b3ChannelId: number
type: string
platform: string
}

export interface StoreBasicInfo {
Expand Down
2 changes: 2 additions & 0 deletions apps/storefront/src/shared/service/b2b/graphql/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ const getStoreChannelId = () => `{
isEnabled
b2bEnabled
b3ChannelId
type
platform
}
timeFormat{
display
Expand Down
25 changes: 14 additions & 11 deletions apps/storefront/src/utils/loginInfo.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ interface ChannelIdProps {
b2bEnabled: boolean
channelLogo: string
b3ChannelId?: number
type: string
platform: string
}

type B2BToken = {
Expand All @@ -37,27 +39,28 @@ export interface ChannelStoreSites {
}

export const getCurrentStoreInfo = (storeSites: Array<ChannelIdProps>) => {
if (storeSites.length === 1) {
return storeSites[0]
}
const newStoreSites =
storeSites.filter(
(site: ChannelIdProps) =>
site.type === 'storefront' && site.platform === 'bigcommerce'
) || []

let store: ChannelIdProps = {
const store: ChannelIdProps = {
channelId: 1,
urls: [],
b2bEnabled: true,
channelLogo: '',
b3ChannelId: 16,
type: 'storefront',
platform: 'bigcommerce',
}

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

storeSites.forEach((item: ChannelIdProps) => {
if (item.urls.includes(origin)) {
store = item
}
})

return store
return storeItem
}

export const getloginTokenInfo = (channelId: number) => {
Expand Down

0 comments on commit 6e083fa

Please sign in to comment.