Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

disable country when editing existing address #303

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading