Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/vtex/address-form
Browse files Browse the repository at this point in the history
  • Loading branch information
kaio-donadelli committed Sep 12, 2023
2 parents 1ad87cc + 5685437 commit 7f40b2e
Show file tree
Hide file tree
Showing 4 changed files with 174 additions and 6 deletions.
17 changes: 17 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,18 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

## [Unreleased]

### Fixed

- Ecuador postal code settings to be more granular and show the cities list during check-out.

## [3.34.6] - 2023-08-24

## [3.34.5] - 2023-08-24

### Added

- Virgin Islands (US) country rules.

## [3.34.4] - 2023-06-27

### Fixed
Expand Down Expand Up @@ -1473,3 +1485,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.

- This Changelog
- **`AddressSubmitter`** component and tests


[Unreleased]: https://github.com/vtex/address-form/compare/v3.34.6...HEAD
[3.34.6]: https://github.com/vtex/address-form/compare/v3.34.5...v3.34.6
[3.34.5]: https://github.com/vtex/address-form/compare/v3.34.4...v3.34.5
2 changes: 1 addition & 1 deletion manifest.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "address-form",
"vendor": "vtex",
"version": "3.34.4",
"version": "3.34.6",
"title": "address-form React component",
"description": "address-form React component",
"defaultLocale": "en",
Expand Down
10 changes: 5 additions & 5 deletions react/country/ECU.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { ONE_LEVEL } from '../constants'
import { firstLevelPostalCodes } from '../transforms/postalCodes'
import { TWO_LEVELS } from '../constants'
import { secondLevelPostalCodes } from '../transforms/postalCodes'
import { getOneLevel, getTwoLevels } from '../transforms/addressFieldsOptions'
import type { PostalCodeRules } from '../types/rules'

Expand Down Expand Up @@ -1278,9 +1278,9 @@ const countryData = {
const rules: PostalCodeRules = {
country: 'ECU',
abbr: 'EC',
postalCodeFrom: ONE_LEVEL,
postalCodeLevels: ['city'],
firstLevelPostalCodes: firstLevelPostalCodes(countryData),
postalCodeFrom: TWO_LEVELS,
postalCodeLevels: ['state', 'city'],
secondLevelPostalCodes: secondLevelPostalCodes(countryData),
fields: [
{
hidden: true,
Expand Down
151 changes: 151 additions & 0 deletions react/country/VIR.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,151 @@
import { POSTAL_CODE } from '../constants'
import type { PostalCodeRules } from '../types/rules'

const rules: PostalCodeRules = {
country: 'VIR',
abbr: 'VI',
postalCodeFrom: POSTAL_CODE,
fields: [
{
hidden: true,
name: 'country',
maxLength: 100,
label: 'country',
size: 'medium',
},
{
name: 'postalCode',
maxLength: 50,
fixedLabel: 'ZIP',
required: true,
mask: '99999-9999',
regex: '^008(01|02|03|04|05|20|21|22|23|24|30|31|40|41|50|51)-\d{0,4}$',
// Asserts zipcode starts with 008, then contains one of the local accepted area values, then followed by hyphen and 4 digits.
postalCodeAPI: true,
forgottenURL: 'https://tools.usps.com/go/ZipLookupAction!input.action',
size: 'small',
autoComplete: 'nope',
},
{
name: 'number',
maxLength: 750,
label: 'number',
hidden: true,
defaultValue: 'N/A',
autoComplete: 'nope',
},
{
name: 'street',
label: 'addressLine1',
required: true,
size: 'xlarge',
},
{
name: 'complement',
maxLength: 750,
label: 'addressLine2',
size: 'xlarge',
},
{
hidden: false,
name: 'neighborhood',
maxLength: 100,
label: 'neighborhood',
size: 'large',
},
{
name: 'city',
maxLength: 100,
label: 'city',
required: true,
size: 'large',
},
{
name: 'state',
maxLength: 100,
label: 'state',
required: true,
hidden: true,
size: 'large',
optionsPairs: [
{ label: 'Virgin Islands', value: 'USVI' },
],
defaultValue: 'USVI'
},
{
hidden: true,
name: 'reference',
maxLength: 750,
label: 'reference',
size: 'xlarge',
},
{
name: 'receiverName',
elementName: 'receiver',
maxLength: 750,
label: 'receiverName',
size: 'xlarge',
required: true,
},
],
geolocation: {
postalCode: {
valueIn: 'long_name',
types: ['postal_code'],
required: false,
},

number: {
valueIn: 'long_name',
types: ['street_number'],
required: false,
notApplicable: true,
},

street: {
valueIn: 'long_name',
types: ['route'],
handler: (address, googleAddress) => {
address.street = { value: (googleAddress as { name: string }).name }

return address
},
},

neighborhood: {
valueIn: 'long_name',
types: [
'neighborhood',
'sublocality_level_1',
'sublocality_level_2',
'sublocality_level_3',
'sublocality_level_4',
'sublocality_level_5',
],
},

state: {
valueIn: 'short_name',
types: ['administrative_area_level_1'],
},

city: {
valueIn: 'long_name',
types: ['locality'],
},

receiverName: {
required: true,
},
},
summary: [
[{ name: 'street' }, { delimiter: ', ', name: 'complement' }],
[
{ name: 'city' },
{ delimiter: ', ', name: 'state' },
{ delimiter: ' ', name: 'postalCode' },
],
],
}

export default rules

0 comments on commit 7f40b2e

Please sign in to comment.