Refactor user service changeAccountInfo function.
This commit is contained in:
parent
563bd20cfe
commit
da6dc6a296
@ -176,7 +176,7 @@ export class TransactionService {
|
||||
const hash = hashFunction.digest();
|
||||
const methodSignature = hash.toString('hex').substring(0, 8);
|
||||
const abiCoder = new utils.AbiCoder();
|
||||
const abi = await abiCoder.encode(
|
||||
const abi = abiCoder.encode(
|
||||
['address', 'address', 'address', 'uint256'],
|
||||
[senderAddress, recipientAddress, tokenAddress, value]
|
||||
);
|
||||
|
@ -83,47 +83,18 @@ export class UserService {
|
||||
locationType: string,
|
||||
oldPhoneNumber: string
|
||||
): Promise<any> {
|
||||
const accountInfo: any = {
|
||||
vcard: {
|
||||
fn: [{}],
|
||||
n: [{}],
|
||||
tel: [{}],
|
||||
},
|
||||
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 accountInfo = await this.loadChangesToAccountStructure(
|
||||
name,
|
||||
phoneNumber,
|
||||
age,
|
||||
type,
|
||||
bio,
|
||||
gender,
|
||||
businessCategory,
|
||||
userLocation,
|
||||
location,
|
||||
locationType
|
||||
);
|
||||
const accountKey: string = await User.toKey(address);
|
||||
this.getAccountDetailsFromMeta(accountKey)
|
||||
.pipe(first())
|
||||
@ -357,4 +328,60 @@ export class UserService {
|
||||
}
|
||||
this.accountsList.next(this.accounts);
|
||||
}
|
||||
|
||||
async loadChangesToAccountStructure(
|
||||
name: string,
|
||||
phoneNumber: string,
|
||||
age: string,
|
||||
type: string,
|
||||
bio: string,
|
||||
gender: string,
|
||||
businessCategory: string,
|
||||
userLocation: string,
|
||||
location: string,
|
||||
locationType: string
|
||||
): Promise<AccountDetails> {
|
||||
const accountInfo: any = {
|
||||
vcard: {
|
||||
fn: [{}],
|
||||
n: [{}],
|
||||
tel: [{}],
|
||||
},
|
||||
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));
|
||||
return accountInfo;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user