diff --git a/src/pages/digitalId/ProfileId.jsx b/src/pages/digitalId/ProfileId.jsx index a1fb4e0..7f4fdeb 100644 --- a/src/pages/digitalId/ProfileId.jsx +++ b/src/pages/digitalId/ProfileId.jsx @@ -14,6 +14,7 @@ const Profile = observer (() => { const [changePanelOpen, setChangePanelOpen] = useState(false); const [toggle, setToggle] = useState(true); const [addPanelOpen, setAddPanelOpen] = useState(false); + const [updatePanelOpen, setUpdatePanelOpen] = useState(false); const [selectedItems, setSelectedItems] = useState([]); const defaultValues = { @@ -32,15 +33,28 @@ const Profile = observer (() => { } } - const changeCurrentValues = (value, field) => { + const addCurrentValues = (value, field) => { setCurrentValues((prevState)=> ({ ...prevState, [field]: value.charAt(0).toUpperCase()+value.slice(1), })) + console.log(currentValues); } + const changeCurrentValue = (value, field, id) => { + setCurrentValues((prevState) => + prevState.map((elem) => ( + elem.id === id ? { + ...elem, + [field]: value.charAt(0).toUpperCase()+value.slice(1), + } : elem + )) + ) + console.log(currentValues); + }; + const closeHint = (element) => { - changeCurrentValues(element, 'property'); + addCurrentValues(element, 'property'); setPropertyValues([]); } @@ -85,11 +99,24 @@ const Profile = observer (() => { setButtonPanelOpen(true); } + const cancelUpdatePanel = () => { + setUpdatePanelOpen(false); + setButtonPanelOpen(true); + } + const openRemovePanel = () => { setRemovePanelOpen(true); setChangePanelOpen(false); } + const openUpdatePanel = () => { + setCurrentValues(selectedUserData); + setUpdatePanelOpen(true); + setChangePanelOpen(false); + console.log(currentValues); + console.log(selectedUserData) + } + const applyRemovePanel = () => { setRemovePanelOpen(false); setButtonPanelOpen(true); @@ -97,7 +124,7 @@ const Profile = observer (() => { } const handleInput = (text, field) => { - changeCurrentValues(text, field); + addCurrentValues(text, field); setPropertyValues(initialPropertyValues); if (text) { let reg = new RegExp(`^${text}`, 'img'); @@ -105,6 +132,8 @@ const Profile = observer (() => { } }; + let selectedUserData = userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key)); + return (