Skip to content

fix: (CXSPA-9504) support Chinese address in address book#21272

Draft
espada945 wants to merge 28 commits intodevelopfrom
bugfix/CXSPA-9504
Draft

fix: (CXSPA-9504) support Chinese address in address book#21272
espada945 wants to merge 28 commits intodevelopfrom
bugfix/CXSPA-9504

Conversation

@espada945
Copy link
Copy Markdown
Member

Summary

  • Add cascading city/district dropdowns when China is selected as country
  • Change "State" label to "Province" for Chinese addresses
  • Make cellphone required for Chinese addresses
  • Add district field for Chinese addresses

Test plan

  • Select China as country → verify city/district dropdowns and Province label
  • Add complete Chinese address → verify successful save
  • Switch to non-China country → verify form reverts to default

Add province/city/district fields for Chinese addresses, make
cellphone required, and display Province instead of State label.
@espada945 espada945 requested review from a team as code owners March 23, 2026 08:32
@github-actions github-actions bot marked this pull request as draft March 23, 2026 08:50
@espada945 espada945 marked this pull request as ready for review March 24, 2026 03:30
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions bot marked this pull request as draft March 24, 2026 03:36
@espada945 espada945 marked this pull request as ready for review March 24, 2026 04:48
@cypress
Copy link
Copy Markdown

cypress bot commented Mar 24, 2026

spartacus    Run #52642

Run Properties:  status check passed Passed #52642  •  git commit 51aba9626f ℹ️: Merge 4ec0863e535e1e111b5afd6c40d198619c442d83 into 96062566bce7cf1b0a2140790069...
Project spartacus
Branch Review bugfix/CXSPA-9504
Run status status check passed Passed #52642
Run duration 04m 11s
Commit git commit 51aba9626f ℹ️: Merge 4ec0863e535e1e111b5afd6c40d198619c442d83 into 96062566bce7cf1b0a2140790069...
Committer espada945
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 3
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 101
View all changes introduced in this branch ↗︎

…pport

- Use inject() for ChineseAddressService instead of modifying constructor
- Rename isChinaAddress to isChineseAddress
- Extract HTTP calls to ChineseAddressService with proper error handling and typed responses
- Use OccEndpointsService.buildUrl() instead of hardcoded URLs
- Reset selectedRegion$/selectedCity$ when switching away from CN
- Reorder form fields: Province before City for Chinese address
- Refresh cities/districts on language change via LanguageService
- Skip address verification for Chinese addresses
- Display city/district/region/country names instead of isocodes in address book
- Add city and cityDistrict fields to Address model
- Request FULL fields for address list API
@github-actions github-actions bot marked this pull request as draft March 26, 2026 08:36
espada945 and others added 5 commits March 26, 2026 17:09
Disable city dropdown until province is selected and district dropdown
until city is selected for Chinese addresses. Show helpful placeholder
text ("Please select a province/city first") when disabled.
- Add province/district/placeholder translations for zh and zh_TW
- Refresh Chinese placeholders on language switch
- Convert cities$/districts$ from observables to arrays with subscriptions
- Fix spec tests to match new array properties
- Fix prettier formatting in occ-user-address.adapter.ts
@espada945 espada945 marked this pull request as ready for review March 31, 2026 05:43
@github-actions
Copy link
Copy Markdown
Contributor

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions bot marked this pull request as draft March 31, 2026 06:11
@espada945 espada945 marked this pull request as ready for review March 31, 2026 06:42
@github-actions github-actions bot marked this pull request as draft March 31, 2026 08:19
@espada945 espada945 marked this pull request as ready for review April 1, 2026 02:18
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions bot marked this pull request as draft April 1, 2026 02:19
@espada945 espada945 marked this pull request as ready for review April 1, 2026 02:22
@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Apr 1, 2026

Merge Checks Failed

Please push a commit to re-trigger the build.
To push an empty commit you can use `git commit --allow-empty -m "Trigger Build"`

@github-actions github-actions bot marked this pull request as draft April 1, 2026 04:43
@espada945 espada945 marked this pull request as ready for review April 1, 2026 05:17
@github-actions github-actions bot marked this pull request as draft April 7, 2026 06:04
@espada945 espada945 marked this pull request as ready for review April 7, 2026 06:34
@github-actions github-actions bot marked this pull request as draft April 7, 2026 07:59
@espada945 espada945 marked this pull request as ready for review April 7, 2026 08:10
@github-actions github-actions bot marked this pull request as draft April 7, 2026 08:38
@i53577 i53577 marked this pull request as ready for review April 7, 2026 08:40
…dapter layer

- Add getCities/getDistricts to UserProfileAdapter, OccUserProfileAdapter,
  UserProfileConnector, UserProfileFacade, and UserProfileService
- Add ChineseCity/ChineseDistrict models to user-profile root
- Remove ChineseAddressService; component now uses UserProfileFacade
- Fix placeholder not updating by adding markForCheck() after translation
- Fix city/district not restored when editing existing Chinese address
…ia OccSiteAdapter

- Remove getCities/getDistricts from UserProfileFacade/Adapter/Connector chain
- Add getCities/getDistricts to UserAddressService delegating to SiteConnector
- Add loadCities/loadDistricts to SiteAdapter and SiteConnector
- Implement HTTP calls in OccSiteAdapter with dedicated OCC endpoints
- Add chineseAddressCities/chineseAddressDistricts endpoint config to default site-context config
- Fix address form: use inline cxTranslate for city/district placeholders to avoid async timing gap
- Fix address form: initialize town/district form controls as null so ng-select shows placeholder
- Fix address form: restore city form control value in edit flow after region cascade reset
@github-actions github-actions bot marked this pull request as draft April 9, 2026 07:10
espada945 and others added 3 commits April 9, 2026 15:22
…ider, prettier formatting

- Add SiteAdapter mock provider to OpfCheckoutBillingAddressFormComponent spec
  (required after SiteConnector was added as UserAddressService dependency)
- Fix prettier formatting in address-form.component.ts
- Use address name instead of isocode for country and region in address card
}
}

protected updateChinesePlaceholders(): void {}
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This empty method is never used.

getCities(
regionIsocode: string
): Observable<{ isocode?: string; name?: string }[]> {
return this.siteConnector.getCities(regionIsocode);
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using NgRx store pattern instead of direct API call would be better for consistency and performance, as getDeliveryCountries() and getRegions() already use.

  1. Performance Issues with Current Implementation

Problem: Multiple API calls for same data
// In address-form.component.ts:194-218
combineLatest([this.selectedRegion$, this.languageService.getActive()])
.pipe(switchMap(([regionIsocode]) => {
return this.userAddressService.getCities(regionIsocode); // 🔴 API call every time!
}))

Every time language changes → new API call
User switches back to previous region → API call again
Multiple address forms on screen → duplicate API calls

  1. Consistency with Existing Architecture

The codebase follows a clear pattern for location data:

Countries → Store (user/store/reducers/delivery-countries.reducer.ts)
Regions → Store (user/store/reducers/regions.reducer.ts)
Cities → Direct API ❌ (breaks pattern)
Districts → Direct API ❌ (breaks pattern)

…ider, prettier formatting

- Add SiteAdapter mock provider to OpfCheckoutBillingAddressFormComponent spec
- Add loadCities/loadDistricts to MockSiteAdapter in site.connector.spec.ts
- Fix prettier formatting in address-form.component.ts
- Display country/region name instead of isocode in address book card
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants