From 4b5976661cd9891354dffc9a5c7186c7da0bd32b Mon Sep 17 00:00:00 2001 From: George Nash Date: Wed, 12 Jun 2024 10:19:24 +0100 Subject: [PATCH] removed logging and reorganised fetching countries --- .../member-info/member-info-edit.component.ts | 72 ++++++++----------- 1 file changed, 29 insertions(+), 43 deletions(-) diff --git a/ui/src/app/home/member-info/member-info-edit.component.ts b/ui/src/app/home/member-info/member-info-edit.component.ts index 2c8c1d918..07d72465e 100644 --- a/ui/src/app/home/member-info/member-info-edit.component.ts +++ b/ui/src/app/home/member-info/member-info-edit.component.ts @@ -65,43 +65,36 @@ export class MemberInfoEditComponent implements OnInit, OnDestroy { ) {} ngOnInit() { - console.log('getting countries') - - this.memberService - .getCountries() - .pipe(take(1)) - .subscribe((countries) => { - this.countries = countries - combineLatest([this.activatedRoute.params, this.accountService.getAccountData()]) - .pipe( - switchMap(([params, account]) => { - if (params['id']) { - this.managedMember = params['id'] - } - if (account) { - this.account = account - if (this.managedMember) { - this.memberService.setManagedMember(params['id']) - return this.memberService.getMemberData(this.managedMember) - } else { - return this.memberService.getMemberData(account?.salesforceId) - } - } else { - return EMPTY - } - }), - takeUntil(this.destroy$) - ) - .subscribe((data) => { - this.memberData = data - this.orgIdsTransformed = Object.entries(this.memberData?.orgIds || {}).flatMap(([name, ids]) => - ids.map((id: string) => ({ id, name })) - ) - this.validateUrl() - if (data) { - this.updateForm(data) + combineLatest([this.activatedRoute.params, this.accountService.getAccountData(), this.memberService.getCountries()]) + .pipe( + switchMap(([params, account, countries]) => { + this.countries = countries + if (params['id']) { + this.managedMember = params['id'] + } + if (account) { + this.account = account + if (this.managedMember) { + this.memberService.setManagedMember(params['id']) + return this.memberService.getMemberData(this.managedMember) + } else { + return this.memberService.getMemberData(account?.salesforceId) } - }) + } else { + return EMPTY + } + }), + takeUntil(this.destroy$) + ) + .subscribe((data) => { + this.memberData = data + this.orgIdsTransformed = Object.entries(this.memberData?.orgIds || {}).flatMap(([name, ids]) => + ids.map((id: string) => ({ id, name })) + ) + this.validateUrl() + if (data) { + this.updateForm(data) + } }) this.editForm.valueChanges.subscribe(() => { @@ -118,8 +111,6 @@ export class MemberInfoEditComponent implements OnInit, OnDestroy { } updateForm(data: ISFMemberData) { - console.log('updating form: billing address is ', data.billingAddress) - if (data && data.id) { this.editForm.patchValue({ orgName: data.name || null, @@ -130,14 +121,9 @@ export class MemberInfoEditComponent implements OnInit, OnDestroy { email: data.publicDisplayEmail, }) if (data.billingAddress) { - console.log('this.countries is ', this.countries) - if (this.countries) { this.country = this.countries.find((country) => country.name === data.billingAddress?.country) - console.log('chosen as currently selected country', this.country) if (this.country) { - console.log('setting states to ', this.country.states) - this.states = this.country.states } else { console.error('Unable to find country: ', data.billingAddress.country)