Skip to content

Commit

Permalink
Fix country fallback on add new address.
Browse files Browse the repository at this point in the history
  • Loading branch information
salesfelipe committed Jun 7, 2019
1 parent edea79b commit 57e44e4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fix

- Fix `country` fallback on add new address.

## [0.27.2] - 2019-05-20

### Fixed
Expand Down
5 changes: 3 additions & 2 deletions manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,6 @@
}
}
}
}
}
},
"$schema": "https://raw.githubusercontent.com/vtex/node-vtex-api/master/gen/manifest.schema"
}
18 changes: 9 additions & 9 deletions react/components/Addresses/AddressEditor.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,19 @@ class AddressEditor extends Component {
const { address } = this.state
const intlId = isNew ? 'addresses.addAddress' : 'addresses.saveAddress'

const validGeoCoords = address.geoCoordinates &&
address.geoCoordinates.valid &&
address.geoCoordinates.geolocationAutoCompleted
const validGeoCoords =
address.geoCoordinates &&
address.geoCoordinates.valid &&
address.geoCoordinates.geolocationAutoCompleted

const validPostalCode = isNew
? address.postalCode.valid && !address.postalCode.geolocationAutoCompleted
: address.postalCode.value !== null

const hasAutoCompletedFields = Object.keys(address).some(
fieldName =>
address && address[fieldName].geolocationAutoCompleted ||
address && address[fieldName].postalCodeAutoCompleted
(address && address[fieldName].geolocationAutoCompleted) ||
(address && address[fieldName].postalCodeAutoCompleted)
)

const shouldUseGoogleMaps =
Expand All @@ -85,12 +86,11 @@ class AddressEditor extends Component {
value: code,
}))

const country = shipsTo && shipsTo.length > 0 ? shipsTo[0] : address.country
const country =
shipsTo && shipsTo.length > 0 ? shipsTo[0] : address.country.value

return (
<AddressRules
country={country}
shouldUseIOFetching>
<AddressRules country={country} shouldUseIOFetching>
<AddressContainer
address={address}
Input={StyleguideInput}
Expand Down

0 comments on commit 57e44e4

Please sign in to comment.