diff --git a/src/pages/Onboarding2.jsx b/src/pages/Onboarding2.jsx index 28126dd..aaf4299 100644 --- a/src/pages/Onboarding2.jsx +++ b/src/pages/Onboarding2.jsx @@ -108,7 +108,7 @@ const Onboarding2 = observer(() => {
diff --git a/src/pages/digitalId/ProfileId.jsx b/src/pages/digitalId/ProfileId.jsx index aad7628..f927d67 100644 --- a/src/pages/digitalId/ProfileId.jsx +++ b/src/pages/digitalId/ProfileId.jsx @@ -26,6 +26,7 @@ const Profile = observer (() => { const [propertyValues, setPropertyValues] = useState([]); const [updatedValues, setUpdatedValues] = useState([defaultValues]); const [addedValues, setAddedValues] = useState(defaultValues); + const [fillingUpdateForm, setFillingUpdateForm] = useState(false); const openHint = () => { if (!addedValues.label) { @@ -38,6 +39,7 @@ const Profile = observer (() => { ...prevState, [field]: value, })) + console.log(addedValues) }; const changeUpdatedValues = (value, field, key) => { @@ -54,6 +56,7 @@ const Profile = observer (() => { const selectHint = (element) => { changeAddedValues(element, 'label'); setPropertyValues([]); + changeAddedValues(); } const closeHint = (eventTarget) => { @@ -62,6 +65,17 @@ const Profile = observer (() => { } }; + const checkFillingUpdateForm = (eventTarget) => { + console.log(eventTarget); + if (eventTarget && eventTarget.id === 'sendingUpdatedValues') { + const checkingCondition = updatedValues.every(item => !Object.keys(item).find(elem => !item[elem])); + if (checkingCondition) { + setFillingUpdateForm(true); + } + } + console.log(updatedValues); + } + const handleSelectedItems = (selectedItems) => { setSelectedItems([...selectedItems]); setUpdatedValues(registrationStore.decryptedUserData.filter(({ key }) => selectedItems.includes(key)) @@ -103,9 +117,12 @@ const Profile = observer (() => { }; const sendUpdatedData = () => { - setUpdatePanelOpen(false); - changeDataParameters(); - setChangePanelOpen(true); + if (fillingUpdateForm) { + setUpdatePanelOpen(false); + changeDataParameters(); + setChangePanelOpen(true); + setFillingUpdateForm(false); + } }; const deleteDataParameters = () => { @@ -138,7 +155,7 @@ const Profile = observer (() => { }; const addDataParameters = () => { - addedValues.key = addedValues.label.toLowerCase().split(' ').join('_'); + addedValues.key = addedValues.label.toLowerCase().split(' ').join(''); registrationStore.pushAccountData(registrationStore.decryptedUserData.concat(addedValues)); }; @@ -149,6 +166,12 @@ const Profile = observer (() => { }; const cancelUpdatePanel = () => { + setUpdatedValues(registrationStore.decryptedUserData.filter(({ key }) => selectedItems.includes(key)) + .map(elem => ( + (!elem.seed) ? { + ...elem, + seed: String(Math.floor(Math.random() * 90000000000000000000), 10), + }: elem))); setUpdatePanelOpen(false); setChangePanelOpen(true); }; @@ -301,6 +324,7 @@ const Profile = observer (() => { @@ -331,6 +355,7 @@ const Profile = observer (() => { type="text" required onChange={(e) => changeUpdatedValues(e.target.value, 'value', item.key)} + onBlur={(e) => checkFillingUpdateForm(e.relatedTarget)} value={item.value} />
@@ -343,6 +368,7 @@ const Profile = observer (() => { type="number" required onChange={(e) => changeUpdatedValues(e.target.value, 'seed', item.key)} + onBlur={(e) => checkFillingUpdateForm(e.relatedTarget)} value={item.seed} /> @@ -373,6 +399,7 @@ const Profile = observer (() => { diff --git a/src/store/store.js b/src/store/store.js index 1b9c370..9e3410d 100644 --- a/src/store/store.js +++ b/src/store/store.js @@ -32,49 +32,49 @@ class Store { reaction(() => this.keysArray, () => this.fetchSharedData()) onBecomeObserved(this, "decryptedUserData", () => this.fetchNewAccountData()) - onBecomeObserved(this, "sharedData", ()=>this.fetchKeysArray()) - onBecomeUnobserved(this, "sharedData", ()=>this.unobservedSharedData()) - onBecomeObserved(this, "transactionsInfo", ()=>this.fetchTransactionsInfo()) - onBecomeUnobserved(this, "transactionsInfo", ()=>this.unobservedTransactionsInfo()) + onBecomeObserved(this, "sharedData", () => this.fetchKeysArray()) + onBecomeUnobserved(this, "sharedData", () => this.unobservedSharedData()) + onBecomeObserved(this, "transactionsInfo", () => this.fetchTransactionsInfo()) + onBecomeUnobserved(this, "transactionsInfo", () => this.unobservedTransactionsInfo()) }; fetchNewAccountData() { getNodeInfo() - .then((info)=>{ - this.fetchNodeInfoSuccess(info) - fetchWrapper.getAuth('data/private', { - networkIdentifier: this.nodeInfo.networkIdentifier, - lastBlockID: this.nodeInfo.lastBlockID - }).then((res) => this.userDataFetchChange(res)) - }) - .catch((err) => this.fetchNodeInfoFailed(err)) + .then((info)=>{ + this.fetchNodeInfoSuccess(info) + fetchWrapper.getAuth('data/private', { + networkIdentifier: this.nodeInfo.networkIdentifier, + lastBlockID: this.nodeInfo.lastBlockID + }).then((res) => this.userDataFetchChange(res)) + }) + .catch((err) => this.fetchNodeInfoFailed(err)) } - pushAccountData(data=this.accountData) { + pushAccountData(data = this.accountData) { fetchWrapper.postAuth('data/private', { networkIdentifier: this.nodeInfo.networkIdentifier, lastBlockID: this.nodeInfo.lastBlockID }, [...this.encryptAccountData(data)]) - .then(()=>this.fetchNewAccountData()) + .then(() => this.fetchNewAccountData()) } fetchKeysArray() { getNodeInfo() - .then((info)=>{ - this.fetchNodeInfoSuccess(info) - fetchWrapper.getAuth('data/shared/', { - networkIdentifier: this.nodeInfo.networkIdentifier, - lastBlockID: this.nodeInfo.lastBlockID - }).then((res) => this.keysArrayFetchChange(res)) - }) - .catch((err) => this.fetchNodeInfoFailed(err)) + .then((info)=>{ + this.fetchNodeInfoSuccess(info) + fetchWrapper.getAuth('data/shared/', { + networkIdentifier: this.nodeInfo.networkIdentifier, + lastBlockID: this.nodeInfo.lastBlockID + }).then((res) => this.keysArrayFetchChange(res)) + }) + .catch((err) => this.fetchNodeInfoFailed(err)) } fetchTransactionsInfo() { fetchWrapper.get(`account/transactions/${this.accountMadeTransaction}?moduleID=1001&assetID=11`, { networkIdentifier: this.nodeInfo.networkIdentifier, lastBlockID: this.nodeInfo.lastBlockID - }).then((res)=>this.saveInfoTransactions(res)) + }).then((res) => this.saveInfoTransactions(res)) } fetchSharedData() { @@ -82,11 +82,11 @@ class Store { }; unobservedTransactionsInfo() { - this._transactionsInfo=[] + this._transactionsInfo = [] } unobservedSharedData() { - this._sharedData=[] + this._sharedData = [] } changeSharedData(incomingData) { @@ -105,8 +105,8 @@ class Store { fetchNodeInfo() { getNodeInfo() - .then((info)=>this.fetchNodeInfoSuccess(info)) - .catch((err) => this.fetchNodeInfoFailed(err)) + .then((info)=>this.fetchNodeInfoSuccess(info)) + .catch((err) => this.fetchNodeInfoFailed(err)) } saveInfoTransactions(transaction) { @@ -139,16 +139,16 @@ class Store { }; get transactionsInfo() { - return this._transactionsInfo.map(item=>{ + return this._transactionsInfo.map(item => { return { id: item.id, - users_images: usersImages.map(image=>{ + users_images: usersImages.map(image => { return { image: image, size: 24 } }), - transaction: item.asset.features.map(asset=>{ + transaction: item.asset.features.map(asset => { return { transaction_id: item.id, address: this.accountMadeTransaction,