import React, { useState } from 'react'; import { userDataStore } from '../../store/userDataStore'; import Sidebar from '../../partials/Sidebar'; import { observer } from 'mobx-react-lite'; import Header from '../../partials/Header'; import ProfileTable from '../../partials/digitalId/ProfileTable'; import Image from '../../images/transactions-image-04.svg'; const Profile = observer (() => { const [sidebarOpen, setSidebarOpen] = useState(false); const [buttonPanelOpen, setButtonPanelOpen] = useState(true); const [removePanelOpen, setRemovePanelOpen] = useState(false); const [changePanelOpen, setChangePanelOpen] = useState(false); 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 [propertyValues, setPropertyValues] = useState([]); const [currentValues, setCurrentValues] = useState(defaultValues); const openHint = () => { if (!currentValues.property) { setPropertyValues(initialPropertyValues); } } const changeCurrentValues = (value, field) => { setCurrentValues((prevState)=> ({ ...prevState, [field]: value.charAt(0).toUpperCase()+value.slice(1), })) } const closeHint = (element) => { changeCurrentValues(element, 'property'); setPropertyValues([]); } const handleSelectedItems = (selectedItems) => { setSelectedItems([...selectedItems]); if (selectedItems.length > 0) { setButtonPanelOpen(false); setAddPanelOpen(false); setChangePanelOpen(true); } if (removePanelOpen === true) { setChangePanelOpen(false); } if (selectedItems.length === 0) { setRemovePanelOpen(false); setButtonPanelOpen(true); setChangePanelOpen(false); } }; const openAddPanel = () => { setAddPanelOpen(true); setButtonPanelOpen(false); } const sendValues = () => { if (!userDataStore.data.some((element) => element.property === currentValues.property) && (currentValues.seed.toString().length === 20)) { setAddPanelOpen(false); setButtonPanelOpen(true); setCurrentValues(defaultValues); } } const cancelAddPanel = () => { setCurrentValues(defaultValues); setAddPanelOpen(false); setButtonPanelOpen(true); } const openRemovePanel = () => { setRemovePanelOpen(true); setChangePanelOpen(false); } const applyRemovePanel = () => { setRemovePanelOpen(false); setButtonPanelOpen(true); } const handleInput = (text, field) => { changeCurrentValues(text, field); setPropertyValues(initialPropertyValues); if (text) { let reg = new RegExp(`^${text}`, 'img'); setPropertyValues((prevState) => prevState.filter((element) => element.match(reg))); } }; return (
{/* Sidebar */} {/* Content area */}
{/* Site header */}
{/* Page header */}
{/* Table */}
{/* Left sidebar */}
{/* Button panel*/}
{/* Add panel */}
handleInput(e.target.value, 'property')} value={currentValues.property} onClick={openHint} />
0) || 'hidden'}`}>
    {propertyValues.map((element, index) => (
  • closeHint(element)}>{element}
  • ))}
setPropertyValues([])} onChange={(e) => changeCurrentValues(e.target.value, 'value')} value={currentValues.value} />
setPropertyValues([])} onChange={(e) => changeCurrentValues(e.target.value, 'seed')} value={currentValues.seed} />
Store data on blockchain
setToggle(!toggle)} />
{/* Buttons */}
{/* Remove panel */}

Summary

{userDataStore.data.filter(({ label }) => selectedItems.includes(label)).map(item => ( {item.label} ))}
On blockchain too
setToggle(!toggle)} />
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do Terms.
{/* Details */}
{/* Top */}
Transaction 04
0.012 IDN
Total amount fee
{/* Divider */}
{/* Change panel */}
) }) export default Profile