Add checks for undefined values before saving metadata to meta server.

This commit is contained in:
Spencer Ofwiti 2021-06-18 19:37:12 +03:00
parent 28f87d7ff9
commit 665b28a8ba
2 changed files with 32 additions and 12 deletions

View File

@ -90,17 +90,37 @@ export class UserService {
},
location: {},
};
if (name) {
accountInfo.vcard.fn[0].value = name;
accountInfo.vcard.n[0].value = name.split(' ');
}
if (phoneNumber) {
accountInfo.vcard.tel[0].value = phoneNumber;
}
if (bio) {
accountInfo.products = [bio];
}
if (gender) {
accountInfo.gender = gender;
}
if (age) {
accountInfo.age = age;
}
if (type) {
accountInfo.type = type;
}
if (businessCategory) {
accountInfo.category = businessCategory;
}
if (location) {
accountInfo.location.area = location;
}
if (userLocation) {
accountInfo.location.area_name = userLocation;
}
if (locationType) {
accountInfo.location.area_type = locationType;
}
await vcardValidation(accountInfo.vcard);
accountInfo.vcard = btoa(vCard.generate(accountInfo.vcard));
const accountKey: string = await User.toKey(address);

View File

@ -94,7 +94,7 @@ export class AccountDetailsComponent implements OnInit {
firstName: ['', Validators.required],
lastName: ['', Validators.required],
phoneNumber: ['', Validators.required],
age: ['', Validators.required],
age: [''],
type: ['', Validators.required],
bio: ['', Validators.required],
gender: ['', Validators.required],