Skip to content

Commit

Permalink
fix: resolve window.b3 build
Browse files Browse the repository at this point in the history
  • Loading branch information
kris liu authored and BrianJiang2021 committed Jul 20, 2022
1 parent c2a6e2d commit 47c60fe
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 18 deletions.
8 changes: 4 additions & 4 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,13 +67,13 @@ export default function Registered() {
const { storeBasicInfo: { storeName } } = await storeB2BBasicInfo()
const registerLogo = getRegisterLogo(quoteConfig)

const newCustomerAccount = customerAccount.length && customerAccount.filter((field: RegisterFileds) => field.custom)
const newCustomerAccount = customerAccount.length ? customerAccount.filter((field: RegisterFileds) => field.custom) : []
const newAdditionalInformation: Array<RegisterFileds> = conversionDataFormat(newCustomerAccount)

const filterCompanyExtraFields = companyExtraFields.length && companyExtraFields.filter((field: RegisterFileds) => field?.visibleToEnduser)
const filterCompanyExtraFields = companyExtraFields.length ? companyExtraFields.filter((field: RegisterFileds) => field?.visibleToEnduser) : []
const newCompanyExtraFields: Array<RegisterFileds> = conversionDataFormat(filterCompanyExtraFields)

const customAddress = billingAddress.length && billingAddress.filter((field: RegisterFileds) => field.custom)
const customAddress = billingAddress.length ? billingAddress.filter((field: RegisterFileds) => field.custom) : []
const addressExtraFields: Array<RegisterFileds> = conversionDataFormat(customAddress)

const newAddressInformationFields = addressInformationFields(b3Lang).map((addressFileds) => {
Expand All @@ -83,7 +83,7 @@ export default function Registered() {
return addressFileds
})

const filterPasswordInformation = customerAccount.length && customerAccount.filter((field: RegisterFileds) => !field.custom && field.fieldType === 'password')
const filterPasswordInformation = customerAccount.length ? customerAccount.filter((field: RegisterFileds) => !field.custom && field.fieldType === 'password') : []
const newPasswordInformation: Array<RegisterFileds> = conversionDataFormat(filterPasswordInformation)
if (dispatch) {
dispatch({
Expand Down
31 changes: 20 additions & 11 deletions apps/storefront/src/pages/registered/RegisteredAccount.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,8 @@ export default function RegisteredAccount(props: RegisteredAccountProps) {
dispatch({ type: 'emailSletter', payload: { emailMarketingNewsletter: event.target.checked } })
}, [])

const additionalList: any = accountType === '1' ? contactInformation : bcContactInformationFields

return (
<Box
sx={{
Expand Down Expand Up @@ -176,17 +178,19 @@ export default function RegisteredAccount(props: RegisteredAccountProps) {
/>
</RadioGroup>
</FormControl>

<Box>
<InformationFourLabels>{b3Lang('intl.user.register.registeredAccount.contactInformation')}</InformationFourLabels>
<B3CustomForm
formFields={accountType === '1' ? contactInformation : bcContactInformationFields}
formFields={additionalList}
errors={errors}
control={control}
getValues={getValues}
setValue={setValue}
/>

</Box>

<Box
sx={{
mt: 4,
Expand All @@ -199,16 +203,21 @@ export default function RegisteredAccount(props: RegisteredAccountProps) {
/>
</Box>
<Box />
<Box>
<InformationFourLabels>{b3Lang('intl.user.register.registeredAccount.additionalInformation')}</InformationFourLabels>
<B3CustomForm
formFields={additionalInformation}
errors={errors}
control={control}
getValues={getValues}
setValue={setValue}
/>
</Box>
{
(additionalInformation && additionalInformation.length) ? (
<Box>
<InformationFourLabels>{b3Lang('intl.user.register.registeredAccount.additionalInformation')}</InformationFourLabels>
<B3CustomForm
formFields={additionalInformation}
errors={errors}
control={control}
getValues={getValues}
setValue={setValue}
/>
</Box>
) : ''
}

<RegisteredStepButton
activeStep={activeStep}
handleBack={handleBack}
Expand Down
6 changes: 3 additions & 3 deletions apps/storefront/src/utils/basicConfig.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const storeHash = (window as any).b3?.setting.storeHash || import.meta.env.VITE_B2B_STOREHASH
const storeHash = (window as any).b3?.setting?.storeHash || import.meta.env.VITE_B2B_STOREHASH

const getCcBaseUrl = () => {
const getBcBaseUrl = () => {
let baseUrl = ''
if (import.meta.env.VITE_NODE_ENV === 'development') {
baseUrl = '/bigcommerce'
Expand All @@ -10,7 +10,7 @@ const getCcBaseUrl = () => {

return baseUrl
}
const bcBaseUrl = getCcBaseUrl()
const bcBaseUrl = getBcBaseUrl()

export {
storeHash,
Expand Down

0 comments on commit 47c60fe

Please sign in to comment.