From 21444304c671ef472ee087dab51f590797f75ba9 Mon Sep 17 00:00:00 2001 From: Spencer Ofwiti Date: Tue, 27 Apr 2021 20:16:12 +0300 Subject: [PATCH] Refactor outgoing metadata to reflect schema. --- src/app/_helpers/schema-validation.ts | 4 ++-- src/app/_services/user.service.ts | 6 +++++- .../accounts/account-details/account-details.component.ts | 2 ++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/_helpers/schema-validation.ts b/src/app/_helpers/schema-validation.ts index d130398..4f1860d 100644 --- a/src/app/_helpers/schema-validation.ts +++ b/src/app/_helpers/schema-validation.ts @@ -4,7 +4,7 @@ async function personValidation(person: any): Promise { const personValidationErrors = await validatePerson(person); if (personValidationErrors) { - personValidationErrors.map(error => console.log(`${error.message}`)); + personValidationErrors.map(error => console.error(`${error.message}`)); } } @@ -12,7 +12,7 @@ async function vcardValidation(vcard: any): Promise { const vcardValidationErrors = await validateVcard(vcard); if (vcardValidationErrors) { - vcardValidationErrors.map(error => console.log(`${error.message}`)); + vcardValidationErrors.map(error => console.error(`${error.message}`)); } } diff --git a/src/app/_services/user.service.ts b/src/app/_services/user.service.ts index 35a284d..f90583a 100644 --- a/src/app/_services/user.service.ts +++ b/src/app/_services/user.service.ts @@ -67,7 +67,8 @@ export class UserService { } async changeAccountInfo(address: string, name: string, phoneNumber: string, age: string, type: string, bio: string, gender: string, - businessCategory: string, userLocation: string, location: string, locationType: string, + businessCategory: string, userLocation: string, location: string, locationType: string, dateRegistered: string, + identities: any, ): Promise { let accountInfo: any = { vcard: { @@ -88,9 +89,12 @@ export class UserService { accountInfo.location.area = location; accountInfo.location.area_name = userLocation; accountInfo.location.area_type = locationType; + accountInfo.date_registered = dateRegistered; + accountInfo.identities = identities; await vcardValidation(accountInfo.vcard); accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard)); await personValidation(accountInfo); + delete accountInfo.identities; const accountKey = await User.toKey(address); this.getAccountDetailsFromMeta(accountKey).pipe(first()).subscribe(async res => { const syncableAccount: Syncable = Envelope.fromJSON(JSON.stringify(res)).unwrap(); diff --git a/src/app/pages/accounts/account-details/account-details.component.ts b/src/app/pages/accounts/account-details/account-details.component.ts index e6d3dd2..8ad7f1a 100644 --- a/src/app/pages/accounts/account-details/account-details.component.ts +++ b/src/app/pages/accounts/account-details/account-details.component.ts @@ -152,6 +152,8 @@ export class AccountDetailsComponent implements OnInit { this.accountInfoFormStub.userLocation.value, this.accountInfoFormStub.location.value, this.accountInfoFormStub.locationType.value, + this.account.date_registered, + this.account.identities ); this.submitted = false; }