diff --git a/src/pages/Onboarding1.jsx b/src/pages/Onboarding1.jsx index 2ec84de..bc6e19d 100644 --- a/src/pages/Onboarding1.jsx +++ b/src/pages/Onboarding1.jsx @@ -1,4 +1,4 @@ -import React, {useEffect} from 'react'; +import React from 'react'; import { Link } from 'react-router-dom'; import OnboardingImage from '../images/onboarding-image.jpg'; @@ -11,9 +11,6 @@ import {registrationStore} from "../store/store"; const Onboarding1 = observer(()=>{ let phrase = passphrase.Mnemonic.generateMnemonic() registrationStore.savePassPhrase(phrase) - useEffect(()=>{ - - },[]) return (
diff --git a/src/pages/Onboarding4.jsx b/src/pages/Onboarding4.jsx index f84f292..bea7ea5 100644 --- a/src/pages/Onboarding4.jsx +++ b/src/pages/Onboarding4.jsx @@ -16,7 +16,6 @@ const Onboarding4 = observer(()=>{ } else { registrationStore.pushAccountData() setCheckBoxesSelected(true) - } } diff --git a/src/pages/digitalId/ProfileId.jsx b/src/pages/digitalId/ProfileId.jsx index 4f5ff20..06c30ad 100644 --- a/src/pages/digitalId/ProfileId.jsx +++ b/src/pages/digitalId/ProfileId.jsx @@ -18,7 +18,7 @@ const Profile = observer (() => { const [selectedItems, setSelectedItems] = useState([]); const defaultValues = { - property: '', + label: '', value: '', seed: Math.floor(Math.random() * 90000000000000000000) }; @@ -29,7 +29,7 @@ const Profile = observer (() => { const [addedValues, setAddedValues] = useState(defaultValues); const openHint = () => { - if (!addedValues.property) { + if (!addedValues.label) { setPropertyValues(initialPropertyValues); } } @@ -63,7 +63,7 @@ const Profile = observer (() => { }; const closeHint = (element) => { - changeAddedValues(element, 'property'); + changeAddedValues(element, 'label'); setPropertyValues([]); } @@ -96,19 +96,53 @@ const Profile = observer (() => { setButtonPanelOpen(false); } - const sendValues = () => { - if (!userDataStore.decryptedData.some((element) => element.property === addedValues.property) && (addedValues.seed.toString().length === 20)) { + const sendAddedData = () => { + if (!userDataStore.decryptedData.some((element) => element.label === addedValues.label) && (addedValues.seed.toString().length === 20)) { setAddPanelOpen(false); setButtonPanelOpen(true); setAddedValues(defaultValues); + addDataParameters(); } } - const deletePropertyData = () => { + const sendUpdatedData = () => { + setUpdatePanelOpen(false); + changeDataParameters(); + setChangePanelOpen(true); + } + + const deleteDataParameters = () => { const changeData = userDataStore.decryptedData.filter(item=>!selectedItems.includes(item.key)) registrationStore.pushAccountData(changeData) } + const changeDataParameters = () => { + const updatedData = (function changeValue() { + let newArr = [] + userDataStore.decryptedData.map(elem => { + updatedValues.forEach(item => { + if (elem.label === item.label) { + newArr.push({ + ...elem, + 'value': item.value, + 'seed': item.seed, + }) + } + }) + if (!newArr.find(element => element.label === elem.label)) { + newArr.push(elem); + } + }) + return newArr + })(); + console.log(updatedData); + } + + const addDataParameters = () => { + addedValues.label = addedValues.label.toLowerCase().split(' ').join('_'); + console.log(registrationStore.userData.data.concat(addedValues)); + } + const cancelAddPanel = () => { setAddedValues(defaultValues); setAddPanelOpen(false); @@ -131,10 +165,10 @@ const Profile = observer (() => { console.log(updatedValues); } - const applyRemovePanel = () => { + const applyDataDeletion = () => { setRemovePanelOpen(false); setButtonPanelOpen(true); - deletePropertyData() + deleteDataParameters() } const handleInput = (text, field) => { @@ -205,12 +239,12 @@ const Profile = observer (() => { handleInput(e.target.value, 'property')} - value={addedValues.property} + onInput={(e) => handleInput(e.target.value, 'label')} + value={addedValues.label} onClick={openHint} />
0) || 'hidden'}`}> @@ -269,7 +303,7 @@ const Profile = observer (() => { @@ -283,11 +317,11 @@ const Profile = observer (() => {
changeUpdatedValues(e.target.value, 'property', item.key)} + onChange={(e) => changeUpdatedValues(e.target.value, 'label', item.key)} value={item.label} disabled='disabled' /> @@ -344,9 +378,9 @@ const Profile = observer (() => {
@@ -372,7 +406,7 @@ const Profile = observer (() => {