fix: (CXSPA-9504) support Chinese address in address book#21272
fix: (CXSPA-9504) support Chinese address in address book#21272
Conversation
Add province/city/district fields for Chinese addresses, make cellphone required, and display Province instead of State label.
Merge Checks Failed |
spartacus
|
||||||||||||||||||||||||||||
| Project |
spartacus
|
| Branch Review |
bugfix/CXSPA-9504
|
| Run status |
|
| Run duration | 04m 11s |
| Commit |
|
| Committer | espada945 |
| View all properties for this run ↗︎ | |
| Test results | |
|---|---|
|
|
0
|
|
|
3
|
|
|
0
|
|
|
0
|
|
|
101
|
| View all changes introduced in this branch ↗︎ | |
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.html
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.spec.ts
Outdated
Show resolved
Hide resolved
…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
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
Merge Checks Failed |
Merge Checks Failed |
Merge Checks Failed |
…ch original format
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Outdated
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-book.component.ts
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/address-form.component.ts
Show resolved
Hide resolved
feature-libs/user/profile/components/address-book/address-form/chinese-address.service.ts
Outdated
Show resolved
Hide resolved
…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
…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 {} |
There was a problem hiding this comment.
This empty method is never used.
| getCities( | ||
| regionIsocode: string | ||
| ): Observable<{ isocode?: string; name?: string }[]> { | ||
| return this.siteConnector.getCities(regionIsocode); |
There was a problem hiding this comment.
Using NgRx store pattern instead of direct API call would be better for consistency and performance, as getDeliveryCountries() and getRegions() already use.
- 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
- 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
Summary
Test plan