Skip to content

Commit

Permalink
Merge pull request #303 from vtex-apps/Fix/country-field-disabling-wh…
Browse files Browse the repository at this point in the history
…en-edit-existing-address

disable country when editing existing address
  • Loading branch information
beatrizmaselli authored Jul 9, 2024
2 parents 6761c09 + e81a555 commit ea6de6e
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 7 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]

## [1.28.0] - 2024-07-09

- Disable country edition for addresses saved at the profile

## [1.27.1] - 2024-02-15

### Fixed
Expand Down
6 changes: 2 additions & 4 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
{
"name": "my-account",
"vendor": "vtex",
"version": "1.27.1",
"version": "1.28.0",
"title": "My Account",
"description": "User's my account page.",
"registries": [
"smartcheckout"
],
"registries": ["smartcheckout"],
"dependencies": {
"vtex.my-cards": "1.x",
"vtex.my-orders-app": "3.x",
Expand Down
21 changes: 18 additions & 3 deletions react/components/Addresses/AddressForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -147,22 +147,36 @@ class AddressForm extends Component<InnerProps & OuterProps, State> {

public render() {
const { address } = this.state
const { intl, submitLabelId, isLoading, googleMapsApiKey, useGeolocation } =
this.props
const {
intl,
submitLabelId,
isLoading,
googleMapsApiKey,
useGeolocation,
isExistingAddress,
} = this.props

const shipCountries = this.translateCountries()
const hasGeoCoords = this.hasGeoCoords()
const hasValidPostalCode = this.hasValidPostalCode()
const hasAutoCompletedFields = this.hasAutoCompletedFields()

const enhancedAddress = {
...address,
country: {
...address.country,
disabled: !!isExistingAddress,
},
}

return (
<AddressRules
country={address.country.value}
shouldUseIOFetching
useGeolocation={useGeolocation}
>
<AddressContainer
address={address}
address={enhancedAddress}
Input={StyleguideInput}
onChangeAddress={this.handleAddressChange}
autoCompletePostalCode
Expand Down Expand Up @@ -258,6 +272,7 @@ interface OuterProps {
receiverName?: string
onError: () => void
onSubmit: (address: Address) => void
isExistingAddress?: boolean
}

type Props = InnerProps & OuterProps
Expand Down
1 change: 1 addition & 0 deletions react/components/pages/AddressEdit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ class AddressEdit extends Component<Props> {
isLoading={isLoading}
submitLabelId="vtex.store-messages@0.x::addresses.saveAddress"
address={normalizedAddress}
isExistingAddress={!!addressId}
onSubmit={this.handleSave}
onError={this.props.handleError}
/>
Expand Down
1 change: 1 addition & 0 deletions react/typings/global.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ declare global {

interface AddressFormFields {
[key: string]: {
disabled: boolean
value: null | string | number | number[]
valid?: boolean
geolocationAutoCompleted?: boolean
Expand Down

0 comments on commit ea6de6e

Please sign in to comment.