Skip to content

Commit

Permalink
feat: country add default value
Browse files Browse the repository at this point in the history
  • Loading branch information
BrianJiang2021 authored and libruce committed Mar 5, 2024
1 parent fb2fe30 commit 05d33a7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 1 deletion.
11 changes: 10 additions & 1 deletion apps/storefront/src/pages/address/components/AddressForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -488,9 +488,18 @@ function AddressForm(
const translatedAddressFields = JSON.parse(JSON.stringify(addressFields))

translatedAddressFields.forEach(
(element: { label: string; idLang: string }) => {
(element: {
label: string
idLang: string
fieldId: string
default: string
}) => {
element.label = b3Lang(element.idLang)

if (!isB2BUser && element.fieldId === 'field_21') {
element.default = ''
}

return element
}
)
Expand Down
6 changes: 6 additions & 0 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,12 @@ function Registered(props: RegisteredProps) {
): Partial<RegisterFieldsItems> => {
if (addressFields.name === 'country') {
addressFields.options = countries
const countryDefaultValue = countries.find(
(country: CustomFieldItems) =>
country.countryName === addressFields.default
)
addressFields.default =
countryDefaultValue?.countryCode || addressFields.default
}
return addressFields
}
Expand Down
4 changes: 4 additions & 0 deletions apps/storefront/src/pages/registered/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ const classificationType = (item: CustomFieldItems) => {
})
}

if (item.fieldId === 'field_country') {
optionItems.default = item.valueConfigs?.default || optionItems.default
}

return optionItems
}

Expand Down

0 comments on commit 05d33a7

Please sign in to comment.