Skip to content

Commit

Permalink
fix: update country can't choose
Browse files Browse the repository at this point in the history
BUN-88
  • Loading branch information
b3aton authored and kris-liu-smile committed Jul 20, 2022
1 parent 116c2cf commit e5d3035
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
5 changes: 3 additions & 2 deletions apps/storefront/src/pages/registered/Registered.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,11 @@ export default function Registered() {
const customAddress = billingAddress.length && billingAddress.filter((field: RegisterFileds) => field.custom)
const addressExtraFields: Array<RegisterFileds> = conversionDataFormat(customAddress)

addressInformationFields(b3Lang).forEach((addressFileds) => {
const newAddressInformationFields = addressInformationFields(b3Lang).map((addressFileds) => {
if (addressFileds.name === 'country') {
addressFileds.options = countries
}
return addressFileds
})

const filterPasswordInformation = customerAccount.length && customerAccount.filter((field: RegisterFileds) => !field.custom && field.fieldType === 'password')
Expand All @@ -97,7 +98,7 @@ export default function Registered() {
companyExtraFields: [...newCompanyExtraFields],
companyInformation: [...companyInformationFields(b3Lang)],
companyAttachment: [...companyAttachmentsFields(b3Lang)],
addressBasicFields: [...addressInformationFields(b3Lang)],
addressBasicFields: [...newAddressInformationFields],
addressExtraFields: [...addressExtraFields],
countryList: [...countries],
passwordInformation: [...newPasswordInformation],
Expand Down
5 changes: 2 additions & 3 deletions apps/storefront/src/pages/registered/RegisteredDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ import { RegisteredContext } from './context/RegisteredContext'
import {
CustomFieldItems,
RegisterFileds,
addressInformationFields,
Country,
State,
Base64,
Expand Down Expand Up @@ -73,7 +72,7 @@ export default function RegisteredDetail(props: any) {

const handleCountryChange = (countryCode: string, stateCode: string = '') => {
const stateList = countryList.find((country: Country) => country.countryCode === countryCode)?.states || []
const stateFields = addressInformationFields(b3Lang).find((formFileds: RegisterFileds) => formFileds.name === 'state')
const stateFields = addressBasicFields.find((formFileds: RegisterFileds) => formFileds.name === 'state')

if (stateFields) {
if (stateList.length > 0) {
Expand All @@ -91,7 +90,7 @@ export default function RegisteredDetail(props: any) {
type: 'stateList',
payload: {
stateList,
addressBasicFields: [...addressInformationFields(b3Lang)],
addressBasicFields: [...addressBasicFields],
},
})
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ interface RegisterState {
companyInformation?: Array<RegisterFileds> | Array<[]>,
companyExtraFields?: Array<RegisterFileds> | Array<[]>,
companyAttachment?: Array<RegisterFileds> | Array<[]>,
addressBasicFields?: Array<RegisterFileds> | Array<[]>,
addressBasicFields?: Array<RegisterFileds>,
addressExtraFields?: Array<RegisterFileds> | Array<[]>,
countryList?: Array<Country>,
stateList?: Array<State>,
Expand Down

0 comments on commit e5d3035

Please sign in to comment.