Refactoring store and association stores into one
This commit is contained in:
@@ -10,8 +10,8 @@ import Logo from "../images/logo.png";
|
||||
const Onboarding2 = observer(()=>{
|
||||
const [dataRegistration, setDataRegistration] = useState(
|
||||
{
|
||||
first_name: '',
|
||||
second_name: '',
|
||||
firstname: '',
|
||||
secondname: '',
|
||||
gender: '',
|
||||
birthdate: '',
|
||||
}
|
||||
@@ -95,11 +95,11 @@ const Onboarding2 = observer(()=>{
|
||||
<div className="space-y-4 mb-8">
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-1" htmlFor="first_name">First name <span className="text-rose-500">*</span></label>
|
||||
<input id="first_name" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="text" />
|
||||
<input id="firstname" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="text" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-1" htmlFor="second_name">Last name <span className="text-rose-500">*</span></label>
|
||||
<input id="second_name" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="text" />
|
||||
<input id="secondname" onChange={(event)=>saveValueChange(event)} className="form-input w-full" type="text" />
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-1" htmlFor="gender">Gender <span className="text-rose-500">*</span></label>
|
||||
|
||||
@@ -23,7 +23,7 @@ const Onboarding4 = observer(()=>{
|
||||
}
|
||||
}
|
||||
|
||||
const firstNameAccount = registrationStore.accountData.length && registrationStore.accountData.find(item=>item.key==="first_name").value
|
||||
const firstNameAccount = registrationStore.accountData.length && registrationStore.accountData.find(item=>item.key==="firstname").value
|
||||
|
||||
return (
|
||||
<main className="bg-white">
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import { userDataStore } from '../../store/userDataStore';
|
||||
import { registrationStore } from "../../store/store";
|
||||
import Sidebar from '../../partials/Sidebar';
|
||||
import { observer } from 'mobx-react-lite';
|
||||
@@ -10,7 +9,7 @@ import Image from '../../images/transactions-image-04.svg';
|
||||
const defaultValues = {
|
||||
label: '',
|
||||
value: '',
|
||||
seed: String(Math.floor(Math.random() * 90000000000000000000), 10)
|
||||
seed: String(Math.floor(Math.random() * 90000000000000000000), 10)
|
||||
};
|
||||
|
||||
const initialPropertyValues = ['First name', 'Second name', 'Birthdate', 'Gender', 'National doctype', 'National doc ID', 'National doc issue date', 'National doc expiry date'];
|
||||
@@ -42,7 +41,7 @@ const Profile = observer (() => {
|
||||
};
|
||||
|
||||
const changeUpdatedValues = (value, field, key) => {
|
||||
setUpdatedValues((prevState) =>
|
||||
setUpdatedValues((prevState) =>
|
||||
prevState.map((elem) => (
|
||||
(elem.key === key) ? {
|
||||
...elem,
|
||||
@@ -65,11 +64,11 @@ const Profile = observer (() => {
|
||||
|
||||
const handleSelectedItems = (selectedItems) => {
|
||||
setSelectedItems([...selectedItems]);
|
||||
setUpdatedValues(userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key))
|
||||
setUpdatedValues(registrationStore.decryptedUserData.filter(({ key }) => selectedItems.includes(key))
|
||||
.map(elem => (
|
||||
(!elem.seed) ? {
|
||||
...elem,
|
||||
seed: String(Math.floor(Math.random() * 90000000000000000000), 10)
|
||||
seed: String(Math.floor(Math.random() * 90000000000000000000), 10)
|
||||
}: elem)));
|
||||
if (selectedItems.length > 0) {
|
||||
setButtonPanelOpen(false);
|
||||
@@ -93,7 +92,7 @@ const Profile = observer (() => {
|
||||
}
|
||||
|
||||
const sendAddedData = () => {
|
||||
const checkingAddedData = !userDataStore.decryptedData
|
||||
const checkingAddedData = !registrationStore.decryptedUserData
|
||||
.some((element) => element.label === addedValues.label) && (addedValues.seed.length === 20);
|
||||
if (checkingAddedData) {
|
||||
setAddPanelOpen(false);
|
||||
@@ -110,18 +109,18 @@ const Profile = observer (() => {
|
||||
}
|
||||
|
||||
const deleteDataParameters = () => {
|
||||
const changeData = userDataStore.decryptedData.filter(item=>!selectedItems.includes(item.key))
|
||||
const changeData = registrationStore.decryptedUserData.filter(item=>!selectedItems.includes(item.key))
|
||||
registrationStore.pushAccountData(changeData);
|
||||
}
|
||||
|
||||
const changeInitialArray = () => {
|
||||
let newArr = [];
|
||||
userDataStore.decryptedData.map(elem => {
|
||||
registrationStore.decryptedUserData.map(elem => {
|
||||
updatedValues.forEach(item => {
|
||||
if (elem.label === item.label) {
|
||||
newArr.push({
|
||||
...elem,
|
||||
'value': item.value,
|
||||
'value': item.value,
|
||||
'seed': item.seed,
|
||||
})
|
||||
}
|
||||
@@ -140,7 +139,7 @@ const Profile = observer (() => {
|
||||
|
||||
const addDataParameters = () => {
|
||||
addedValues.key = addedValues.label.toLowerCase().split(' ').join('_');
|
||||
registrationStore.pushAccountData(userDataStore.decryptedData.concat(addedValues));
|
||||
registrationStore.pushAccountData(registrationStore.decryptedUserData.concat(addedValues));
|
||||
}
|
||||
|
||||
const cancelAddPanel = () => {
|
||||
@@ -212,7 +211,7 @@ const Profile = observer (() => {
|
||||
</ul>
|
||||
</div>
|
||||
{/* Table */}
|
||||
<ProfileTable selectedItems={handleSelectedItems} userData={userDataStore.decryptedData}/>
|
||||
<ProfileTable selectedItems={handleSelectedItems} userData={registrationStore.decryptedUserData}/>
|
||||
</div>
|
||||
{/* Left sidebar */}
|
||||
<div>
|
||||
@@ -309,7 +308,7 @@ const Profile = observer (() => {
|
||||
</div>
|
||||
{/* Update panel */}
|
||||
<div className={`${!updatePanelOpen && 'hidden'} bg-white p-5 shadow-lg rounded-sm border border-slate-200 lg:w-72 xl:w-80 mb-11`}>
|
||||
{updatedValues.map((item, index) => (
|
||||
{updatedValues.map((item, index) => (
|
||||
<div key={index} className="flex flex-col gap-y-3">
|
||||
<div>
|
||||
<label className="block text-sm font-medium mb-1" htmlFor="mandatory">Property <span className="text-rose-500">*</span></label>
|
||||
@@ -383,7 +382,7 @@ const Profile = observer (() => {
|
||||
<div className={`${!removePanelOpen && 'hidden'} bg-white px-5 pt-4 pb-[190px] shadow-lg rounded-sm border border-slate-200 lg:w-72 xl:w-80 mb-12`}>
|
||||
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2">Summary</h2>
|
||||
<div className="flex flex-col">
|
||||
{userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key)).map(item => (
|
||||
{registrationStore.decryptedUserData.filter(({ key }) => selectedItems.includes(key)).map(item => (
|
||||
<span key={item.label} className="text-sm font-normal text-slate-600 py-3 border-b border-slate-200">{item.label}</span>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import React, { useState } from 'react';
|
||||
import {observer} from "mobx-react-lite";
|
||||
|
||||
import {transactionsStore} from "../../store/transactionsStore";
|
||||
import Sidebar from '../../partials/Sidebar';
|
||||
import Header from '../../partials/Header';
|
||||
import ValidateTable from "../../partials/validate/ValidateTable";
|
||||
import ValidatePanel from "../../partials/validate/ValidatePanel";
|
||||
import ValidateRoadMap from "../../partials/validationlog/ValidateRoadMap";
|
||||
import {Link} from "react-router-dom";
|
||||
import {registrationStore} from "../../store/store";
|
||||
|
||||
const Validate = observer(()=>{
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
@@ -58,7 +58,7 @@ const Validate = observer(()=>{
|
||||
<div className="pb-8 border-b border-zinc-200 mt-[50px]">
|
||||
<h1 className="text-2xl md:text-3xl text-slate-800 font-bold">Digital ID validation log ✨</h1>
|
||||
</div>
|
||||
{transactionsStore.transactionsData.map(item => {
|
||||
{registrationStore.transactionsInfo.map(item => {
|
||||
return <ValidateRoadMap season={item} key={item.id}/>
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
import React, {useState} from 'react';
|
||||
|
||||
import ValidateRoadMap from "../../partials/validationlog/ValidateRoadMap";
|
||||
import {transactionsStore} from "../../store/transactionsStore";
|
||||
import {observer} from "mobx-react-lite";
|
||||
import Sidebar from '../../partials/Sidebar';
|
||||
import Header from '../../partials/Header';
|
||||
import {registrationStore} from "../../store/store";
|
||||
|
||||
const ValidationLog = observer(()=>{
|
||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||
@@ -28,7 +28,7 @@ const ValidationLog = observer(()=>{
|
||||
<div className="max-w-3xl m-auto mt-6">
|
||||
<div className="xl:-translate-x-16 max-w-fit">
|
||||
{/* PostsID */}
|
||||
{transactionsStore.transactionsData.map(item=>{
|
||||
{registrationStore.transactionsInfo.map(item=>{
|
||||
return <ValidateRoadMap season={item} key={item.id}/>
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import React, { useState } from 'react';
|
||||
import Sidebar from '../../partials/Sidebar';
|
||||
import Header from '../../partials/Header';
|
||||
import { sharedDataStore } from '../../store/sharedDataStore';
|
||||
import {registrationStore} from "../../store/store";
|
||||
import { observer } from 'mobx-react-lite';
|
||||
|
||||
const Verify = observer(() => {
|
||||
@@ -42,7 +42,7 @@ const Verify = observer(() => {
|
||||
</div>
|
||||
{/* Block */}
|
||||
<div className="flex flex-col gap-y-4">
|
||||
{sharedDataStore.sharedData.map((item, index) => (
|
||||
{registrationStore.sharedData.map((item, index) => (
|
||||
<div key={index} className="w-[1095px] pl-5 pr-[13px] pb-8 bg-white border border-slate-200 rounded shadow-[0_4px_6px_-1px_rgba(5,23,42,0.08)]">
|
||||
{/* Header */}
|
||||
<div className="flex justify-end items-center h-[42px]">
|
||||
@@ -81,7 +81,7 @@ const Verify = observer(() => {
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
@@ -91,4 +91,4 @@ const Verify = observer(() => {
|
||||
)
|
||||
})
|
||||
|
||||
export default Verify;
|
||||
export default Verify;
|
||||
|
||||
Reference in New Issue
Block a user