diff --git a/src/pages/digitalId/ProfileId.jsx b/src/pages/digitalId/ProfileId.jsx
index 7819184..abc710b 100644
--- a/src/pages/digitalId/ProfileId.jsx
+++ b/src/pages/digitalId/ProfileId.jsx
@@ -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';
@@ -14,14 +15,14 @@ const Profile = observer (() => {
const [toggle, setToggle] = useState(true);
const [addPanelOpen, setAddPanelOpen] = useState(false);
const [selectedItems, setSelectedItems] = useState([]);
-
+
const defaultValues = {
property: '',
value: '',
seed: Math.floor(Math.random() * 90000000000000000000)
};
- const initialPropertyValues = ['First name', 'Second name', 'Birthdate', 'Gender', 'Residence', 'Document type', 'Document ID', 'Issue date', 'Expiry date'];
+ const initialPropertyValues = ['First name', 'Second name', 'Birthdate', 'Gender', 'Residence', 'Document type', 'Document ID', 'Issue date', 'Expiry date'];
const [propertyValues, setPropertyValues] = useState([]);
const [currentValues, setCurrentValues] = useState(defaultValues);
@@ -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 (() => {
Summary
- {userDataStore.decryptedData.filter(({ label }) => selectedItems.includes(label)).map(item => (
+ {userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key)).map(item => (
{item.label}
))}
@@ -335,4 +342,4 @@ const Profile = observer (() => {
)
})
-export default Profile
\ No newline at end of file
+export default Profile
diff --git a/src/partials/digitalId/ProfileTable.jsx b/src/partials/digitalId/ProfileTable.jsx
index b65797b..4033abf 100644
--- a/src/partials/digitalId/ProfileTable.jsx
+++ b/src/partials/digitalId/ProfileTable.jsx
@@ -38,7 +38,7 @@ function ProfileTable({
const generalData = userData.filter(elem => data.general.includes(elem.label)),
nationalityData = userData.filter(elem => data.nationality.includes(elem.label)),
sosialData = userData.filter(elem => data.nationality.includes(elem.label)),
- otherData = userData.filter((elem) =>
+ otherData = userData.filter((elem) =>
!data.general.includes(elem.label) && !data.nationality.includes(elem.label) && !data.social.includes(elem.label));
return (
@@ -53,7 +53,7 @@ function ProfileTable({
return (
)
})}
@@ -115,7 +115,7 @@ function ProfileTable({
handleClick={handleClick}
isChecked={isCheck.includes(data.label)}
/>
- )
+ )
})}
diff --git a/src/store/store.js b/src/store/store.js
index 1ee0ac4..c94784a 100644
--- a/src/store/store.js
+++ b/src/store/store.js
@@ -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'
}
diff --git a/src/store/userDataStore.js b/src/store/userDataStore.js
index 2dd65ab..d0c7dfc 100644
--- a/src/store/userDataStore.js
+++ b/src/store/userDataStore.js
@@ -11,7 +11,7 @@ const labelMap = {
nationality: "Nationality",
national_id: "National id",
national_doctype: "National doctype",
- national_doc_id: "National doc id",
+ national_doc_id: "National doc id",
national_doc_issue_date: "National doc issue date",
national_doc_expiry_date: "National doc expiry date",
telephone: "Telephone",
@@ -40,14 +40,14 @@ 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]
}))
}
}
-export const userDataStore = new UserDataStore();
\ No newline at end of file
+export const userDataStore = new UserDataStore();