changed the names of the methods

This commit is contained in:
Daria Golova
2022-07-06 19:32:31 +03:00
parent 944c9989e9
commit 18bf373508
4 changed files with 53 additions and 23 deletions

View File

@@ -1,4 +1,4 @@
import React, {useEffect} from 'react'; import React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import OnboardingImage from '../images/onboarding-image.jpg'; import OnboardingImage from '../images/onboarding-image.jpg';
@@ -11,9 +11,6 @@ import {registrationStore} from "../store/store";
const Onboarding1 = observer(()=>{ const Onboarding1 = observer(()=>{
let phrase = passphrase.Mnemonic.generateMnemonic() let phrase = passphrase.Mnemonic.generateMnemonic()
registrationStore.savePassPhrase(phrase) registrationStore.savePassPhrase(phrase)
useEffect(()=>{
},[])
return ( return (
<main className="bg-white"> <main className="bg-white">

View File

@@ -16,7 +16,6 @@ const Onboarding4 = observer(()=>{
} else { } else {
registrationStore.pushAccountData() registrationStore.pushAccountData()
setCheckBoxesSelected(true) setCheckBoxesSelected(true)
} }
} }

View File

@@ -18,7 +18,7 @@ const Profile = observer (() => {
const [selectedItems, setSelectedItems] = useState([]); const [selectedItems, setSelectedItems] = useState([]);
const defaultValues = { const defaultValues = {
property: '', label: '',
value: '', value: '',
seed: Math.floor(Math.random() * 90000000000000000000) seed: Math.floor(Math.random() * 90000000000000000000)
}; };
@@ -29,7 +29,7 @@ const Profile = observer (() => {
const [addedValues, setAddedValues] = useState(defaultValues); const [addedValues, setAddedValues] = useState(defaultValues);
const openHint = () => { const openHint = () => {
if (!addedValues.property) { if (!addedValues.label) {
setPropertyValues(initialPropertyValues); setPropertyValues(initialPropertyValues);
} }
} }
@@ -63,7 +63,7 @@ const Profile = observer (() => {
}; };
const closeHint = (element) => { const closeHint = (element) => {
changeAddedValues(element, 'property'); changeAddedValues(element, 'label');
setPropertyValues([]); setPropertyValues([]);
} }
@@ -96,19 +96,53 @@ const Profile = observer (() => {
setButtonPanelOpen(false); setButtonPanelOpen(false);
} }
const sendValues = () => { const sendAddedData = () => {
if (!userDataStore.decryptedData.some((element) => element.property === addedValues.property) && (addedValues.seed.toString().length === 20)) { if (!userDataStore.decryptedData.some((element) => element.label === addedValues.label) && (addedValues.seed.toString().length === 20)) {
setAddPanelOpen(false); setAddPanelOpen(false);
setButtonPanelOpen(true); setButtonPanelOpen(true);
setAddedValues(defaultValues); setAddedValues(defaultValues);
addDataParameters();
} }
} }
const deletePropertyData = () => { const sendUpdatedData = () => {
setUpdatePanelOpen(false);
changeDataParameters();
setChangePanelOpen(true);
}
const deleteDataParameters = () => {
const changeData = userDataStore.decryptedData.filter(item=>!selectedItems.includes(item.key)) const changeData = userDataStore.decryptedData.filter(item=>!selectedItems.includes(item.key))
registrationStore.pushAccountData(changeData) 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 = () => { const cancelAddPanel = () => {
setAddedValues(defaultValues); setAddedValues(defaultValues);
setAddPanelOpen(false); setAddPanelOpen(false);
@@ -131,10 +165,10 @@ const Profile = observer (() => {
console.log(updatedValues); console.log(updatedValues);
} }
const applyRemovePanel = () => { const applyDataDeletion = () => {
setRemovePanelOpen(false); setRemovePanelOpen(false);
setButtonPanelOpen(true); setButtonPanelOpen(true);
deletePropertyData() deleteDataParameters()
} }
const handleInput = (text, field) => { const handleInput = (text, field) => {
@@ -205,12 +239,12 @@ const Profile = observer (() => {
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Property <span className="text-rose-500">*</span></label> <label className="block text-sm font-medium mb-1" htmlFor="mandatory">Property <span className="text-rose-500">*</span></label>
<input <input
autoComplete='off' autoComplete='off'
id="property" id="label"
className="form-input w-full" className="form-input w-full"
type="text" type="text"
required required
onInput={(e) => handleInput(e.target.value, 'property')} onInput={(e) => handleInput(e.target.value, 'label')}
value={addedValues.property} value={addedValues.label}
onClick={openHint} onClick={openHint}
/> />
<div className={`flex flex-col gap-y-2 py-2 pl-2 border border-t-0 border-slate-200 rounded ${(propertyValues.length > 0) || 'hidden'}`}> <div className={`flex flex-col gap-y-2 py-2 pl-2 border border-t-0 border-slate-200 rounded ${(propertyValues.length > 0) || 'hidden'}`}>
@@ -269,7 +303,7 @@ const Profile = observer (() => {
</button> </button>
<button <button
className="btn-sm bg-indigo-500 hover:bg-indigo-600 text-white" className="btn-sm bg-indigo-500 hover:bg-indigo-600 text-white"
onClick={sendValues} onClick={sendAddedData}
> >
Send Send
</button> </button>
@@ -283,11 +317,11 @@ const Profile = observer (() => {
<div> <div>
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Property <span className="text-rose-500">*</span></label> <label className="block text-sm font-medium mb-1" htmlFor="mandatory">Property <span className="text-rose-500">*</span></label>
<input <input
id={`${item.key}:property`} id={`${item.key}:label`}
className="form-input w-full" className="form-input w-full"
type="text" type="text"
required required
onChange={(e) => changeUpdatedValues(e.target.value, 'property', item.key)} onChange={(e) => changeUpdatedValues(e.target.value, 'label', item.key)}
value={item.label} value={item.label}
disabled='disabled' disabled='disabled'
/> />
@@ -344,9 +378,9 @@ const Profile = observer (() => {
</button> </button>
<button <button
className="btn-sm bg-indigo-500 hover:bg-indigo-600 text-white" className="btn-sm bg-indigo-500 hover:bg-indigo-600 text-white"
onClick={sendValues} onClick={sendUpdatedData}
> >
Apply Send
</button> </button>
</div> </div>
</div> </div>
@@ -372,7 +406,7 @@ const Profile = observer (() => {
<div className="flex flex-row justify-end gap-x-2 pt-[20px] pb-[16px] items-end"> <div className="flex flex-row justify-end gap-x-2 pt-[20px] pb-[16px] items-end">
<button <button
className="btn w-full bg-indigo-500 hover:bg-indigo-600 text-white px-[100px] justify-start" className="btn w-full bg-indigo-500 hover:bg-indigo-600 text-white px-[100px] justify-start"
onClick={applyRemovePanel} onClick={applyDataDeletion}
> >
<svg className="w-4 h-4 fill-current shrink-0" viewBox="0 0 16 16"> <svg className="w-4 h-4 fill-current shrink-0" viewBox="0 0 16 16">
<path d="m2.457 8.516.969-.99 2.516 2.481 5.324-5.304.985.989-6.309 6.284z" /> <path d="m2.457 8.516.969-.99 2.516 2.481 5.324-5.304.985.989-6.309 6.284z" />

View File

@@ -48,7 +48,7 @@ class Store {
} }
saveDataRegistration(data) { saveDataRegistration(data) {
this._accountData = data; this._accountData = [data];
}; };
fetchNodeInfo() { fetchNodeInfo() {