Skip to content

Commit

Permalink
fix: correct countries are loaded
Browse files Browse the repository at this point in the history
  • Loading branch information
MiguelPelegrina committed Dec 11, 2023
1 parent 3d93781 commit a8d70a5
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<!-- COUNTRY -->
<mat-form-field class="form-group w-100">
<mat-label>Country</mat-label>
<mat-select formControlName="country" (selectionChange)="onCountrySelected($event.value)" [(value)]="selectedCountry">
<mat-select formControlName="country" (selectionChange)="onCountrySelected()" [(value)]="selectedCountry">
<mat-option *ngFor="let country of countries" [value]="country.name">
{{country.name}}
</mat-option>
Expand All @@ -21,7 +21,7 @@
<!-- CITY -->
<mat-form-field class="form-group w-100">
<mat-label>City</mat-label>
<mat-select [attr.disabled]="!selectedCountry" formControlName="city" (selectionChange)="onCitySelected($event.value)" [(value)]="selectedCity">
<mat-select [attr.disabled]="!selectedCountry" formControlName="city" (selectionChange)="onCitySelected()" [(value)]="selectedCity">
<mat-option *ngFor="let city of cities" [value]="city.name">
{{city.name}}
</mat-option>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ export class AddEditAddressForm extends AbstractForm implements OnDestroy, OnIni
* Handles the city selection event. Loads postal codes based on the selected city.
* @param city The selected city.
*/
protected onCitySelected(city: City): void{
this.postalCodeService.getAll(true, city.name).subscribe(() => {
protected onCitySelected(): void{
this.postalCodeService.getAll(true, this.selectedCity).subscribe(() => {
this.selectedPostalCode = '';
this.loadPostalCodes();
})
Expand All @@ -108,8 +108,8 @@ export class AddEditAddressForm extends AbstractForm implements OnDestroy, OnIni
* Handles the country selection event. Loads cities and resets selected city and postal code.
* @param country The selected country.
*/
protected onCountrySelected(country: Country): void{
this.cityService.getAll(true, country.name).subscribe(() => {
protected onCountrySelected(): void{
this.cityService.getAll(true, this.selectedCountry).subscribe(() => {
this.selectedCity = '';
this.selectedPostalCode = '';
this.loadCities();
Expand All @@ -121,7 +121,7 @@ export class AddEditAddressForm extends AbstractForm implements OnDestroy, OnIni
* Loads cities based on the selected country.
*/
private loadCities(): void{
this.citySubscription = this.cityService.getAll(true,this.selectedCountry).subscribe(cityList => {
this.citySubscription = this.cityService.getAll(true, this.selectedCountry).subscribe(cityList => {
this.cities = cityList;
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/app/services/city/city.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ export class CityService extends AbstractService<City, string> {
public override getAll(active?: boolean, name?: string): Observable<any> {
const queryParams = this.queryBuilderService.buildQueryParams({
active,
name: name
country_name: name
});

const searchUrl = `${this.baseUrl}/search${queryParams}`;
Expand Down

0 comments on commit a8d70a5

Please sign in to comment.