Merge pull request #27 from franze6/DID-6

Add method for delete property account
This commit is contained in:
Kirill Andrusyak
2022-07-06 12:28:46 +03:00
committed by GitHub
4 changed files with 37 additions and 15 deletions

View File

@@ -1,5 +1,6 @@
import React, { useState } from 'react';
import { userDataStore } from '../../store/userDataStore';
import { registrationStore } from "../../store/store";
import Sidebar from '../../partials/Sidebar';
import { observer } from 'mobx-react-lite';
import Header from '../../partials/Header';
@@ -73,6 +74,11 @@ const Profile = observer (() => {
}
}
const deletePropertyData = () => {
const changeData = registrationStore.userData.data.filter(item=>!selectedItems.includes(item.label))
registrationStore.fetchChangeAccountData(changeData)
}
const cancelAddPanel = () => {
setCurrentValues(defaultValues);
setAddPanelOpen(false);
@@ -87,6 +93,7 @@ const Profile = observer (() => {
const applyRemovePanel = () => {
setRemovePanelOpen(false);
setButtonPanelOpen(true);
deletePropertyData()
}
const handleInput = (text, field) => {
@@ -231,7 +238,7 @@ const Profile = observer (() => {
<div className={`${!removePanelOpen && 'hidden'} bg-white px-5 pt-4 pb-[190px] shadow-lg rounded-sm border border-slate-200 lg:w-72 xl:w-80 mb-12`}>
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2">Summary</h2>
<div className="flex flex-col">
{userDataStore.decryptedData.filter(({ label }) => selectedItems.includes(label)).map(item => (
{userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key)).map(item => (
<span key={item.label} className="text-sm font-normal text-slate-600 py-3 border-b border-slate-200">{item.label}</span>
))}
</div>

View File

@@ -53,7 +53,7 @@ function ProfileTable({
return (
<ProfileTableItem
key={data.label}
id={data.label}
id={data.key}
image={defaultData.image}
value={data.value.charAt(0).toUpperCase()+data.value.slice(1)}
property={data.label}
@@ -61,7 +61,7 @@ function ProfileTable({
transactions={defaultData.transactions}
avatars={defaultData.avatars}
handleClick={handleClick}
isChecked={isCheck.includes(data.label)}
isChecked={isCheck.includes(data.key)}
/>
)
})}

View File

@@ -30,10 +30,29 @@ class Store {
}, [...this.encryptAccountData]).catch(()=>{})
};
fetchNewAccountData() {
fetchWrapper.getAuth('http://3.125.47.101/api/data/private', {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
}).then((res) => this.userDataFetchChange(res))
}
fetchChangeAccountData(data) {
fetchWrapper.postAuth('http://3.125.47.101/api/data/private', {
networkIdentifier: this.nodeInfo.networkIdentifier,
lastBlockID: this.nodeInfo.lastBlockID
}, [...data])
.then(()=>this.fetchNewAccountData())
}
userDataFetchChange(res) {
this._userData = res;
}
get userData() {
return this._userData
}
savePassPhrase(phrase) {
this._passPhrase = phrase
}
@@ -56,10 +75,6 @@ class Store {
console.log(err)
}
get userData() {
return this._userData;
}
get passPhrase() {
return 'rocket north inform swift improve fringe sweet crew client canyon bean autumn'
}

View File

@@ -40,10 +40,10 @@ class UserDataStore{
this._data = data.data;
})
}
get decryptedData(){
return this._data.map((elem) => ({
...elem,
key: elem.label,
label: labelMap[elem.label],
value: cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, registrationStore.passPhrase, registrationStore.pubKey).split(':')[1]
}))