Refactor outgoing metadata to reflect schema.

This commit is contained in:
Spencer Ofwiti 2021-04-27 20:16:12 +03:00
parent cb14b9b5dc
commit 21444304c6
3 changed files with 9 additions and 3 deletions

View File

@ -4,7 +4,7 @@ async function personValidation(person: any): Promise<void> {
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<void> {
const vcardValidationErrors = await validateVcard(vcard);
if (vcardValidationErrors) {
vcardValidationErrors.map(error => console.log(`${error.message}`));
vcardValidationErrors.map(error => console.error(`${error.message}`));
}
}

View File

@ -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<any> {
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();

View File

@ -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;
}