Skip to content

Commit

Permalink
feat: api config
Browse files Browse the repository at this point in the history
  • Loading branch information
kris liu authored and kris-liu-smile committed Jul 20, 2022
1 parent 34ae319 commit 2ae621d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
2 changes: 1 addition & 1 deletion apps/storefront/.env.development
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
NODE_ENV=development
VITE_NODE_ENV=development
VITE_B2B_BASIC_URL=https://dev-v2.bundleb2b.net
VITE_B2B_STOREHASH='rtmh8fqr05'
1 change: 1 addition & 0 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function Registered() {
},
})
}

const { customerAccount, billingAddress } = await getBCRegisterCustomFields()
const { companyExtraFields } = await getB2BRegisterCustomFields()
const { quoteConfig } = await getB2BRegisterLogo()
Expand Down
3 changes: 2 additions & 1 deletion apps/storefront/src/shared/service/bc/api/register.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { B3Request } from '../../request/b3Fetch'
import { RequestType } from '../../request/base'
import { bcBaseUrl } from '../../../../utils/basicConfig'

export const getBCRegisterCustomFields = (): any => B3Request.get('/bigcommerce/api/storefront/form-fields', RequestType.BCRest)
export const getBCRegisterCustomFields = (): any => B3Request.get(`${bcBaseUrl}/api/storefront/form-fields`, RequestType.BCRest)
13 changes: 13 additions & 0 deletions apps/storefront/src/utils/basicConfig.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,18 @@
const storeHash = (window as any).b3?.setting.storeHash || import.meta.env.VITE_B2B_STOREHASH

const getCcBaseUrl = () => {
let baseUrl = ''
if (import.meta.env.VITE_NODE_ENV === 'development') {
baseUrl = '/bigcommerce'
} else {
baseUrl = ''
}

return baseUrl
}
const bcBaseUrl = getCcBaseUrl()

export {
storeHash,
bcBaseUrl,
}

0 comments on commit 2ae621d

Please sign in to comment.