converted user data into Map object

This commit is contained in:
Daria Golova
2022-07-01 16:03:21 +03:00
parent e883b190a7
commit 16ca8a1df2
2 changed files with 66 additions and 38 deletions

View File

@@ -4,7 +4,7 @@ import { registrationStore } from './store';
class UserDataStore{
_data = []
constructor() {
makeAutoObservable(this);
@@ -13,12 +13,17 @@ class UserDataStore{
})
}
get data(){
return this._data.map((elem) => ({
...elem,
label: elem.label.charAt(0).toUpperCase()+elem.label.slice(1).split('_').join(' '),
value: cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, registrationStore.passPhrase, registrationStore.pubKey).split(':')[1]
}))
get data() {
return this._data;
}
get decryptData(){
const labelMap = new Map;
this._data.forEach(elem =>
labelMap.set(elem.label.charAt(0).toUpperCase()+elem.label.slice(1).split('_').join(' '),
cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, registrationStore.passPhrase, registrationStore.pubKey).split(':')[1]
)
)
return labelMap;
}
}