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 Onboarding2 = observer(()=>{
|
||||||
const [dataRegistration, setDataRegistration] = useState(
|
const [dataRegistration, setDataRegistration] = useState(
|
||||||
{
|
{
|
||||||
first_name: '',
|
firstname: '',
|
||||||
second_name: '',
|
secondname: '',
|
||||||
gender: '',
|
gender: '',
|
||||||
birthdate: '',
|
birthdate: '',
|
||||||
}
|
}
|
||||||
@@ -95,11 +95,11 @@ const Onboarding2 = observer(()=>{
|
|||||||
<div className="space-y-4 mb-8">
|
<div className="space-y-4 mb-8">
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1" htmlFor="first_name">First name <span className="text-rose-500">*</span></label>
|
<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>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1" htmlFor="second_name">Last name <span className="text-rose-500">*</span></label>
|
<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>
|
||||||
<div>
|
<div>
|
||||||
<label className="block text-sm font-medium mb-1" htmlFor="gender">Gender <span className="text-rose-500">*</span></label>
|
<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 (
|
return (
|
||||||
<main className="bg-white">
|
<main className="bg-white">
|
||||||
|
|||||||
@@ -1,5 +1,4 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import { userDataStore } from '../../store/userDataStore';
|
|
||||||
import { registrationStore } from "../../store/store";
|
import { registrationStore } from "../../store/store";
|
||||||
import Sidebar from '../../partials/Sidebar';
|
import Sidebar from '../../partials/Sidebar';
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
@@ -65,7 +64,7 @@ const Profile = observer (() => {
|
|||||||
|
|
||||||
const handleSelectedItems = (selectedItems) => {
|
const handleSelectedItems = (selectedItems) => {
|
||||||
setSelectedItems([...selectedItems]);
|
setSelectedItems([...selectedItems]);
|
||||||
setUpdatedValues(userDataStore.decryptedData.filter(({ key }) => selectedItems.includes(key))
|
setUpdatedValues(registrationStore.decryptedUserData.filter(({ key }) => selectedItems.includes(key))
|
||||||
.map(elem => (
|
.map(elem => (
|
||||||
(!elem.seed) ? {
|
(!elem.seed) ? {
|
||||||
...elem,
|
...elem,
|
||||||
@@ -93,7 +92,7 @@ const Profile = observer (() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const sendAddedData = () => {
|
const sendAddedData = () => {
|
||||||
const checkingAddedData = !userDataStore.decryptedData
|
const checkingAddedData = !registrationStore.decryptedUserData
|
||||||
.some((element) => element.label === addedValues.label) && (addedValues.seed.length === 20);
|
.some((element) => element.label === addedValues.label) && (addedValues.seed.length === 20);
|
||||||
if (checkingAddedData) {
|
if (checkingAddedData) {
|
||||||
setAddPanelOpen(false);
|
setAddPanelOpen(false);
|
||||||
@@ -110,13 +109,13 @@ const Profile = observer (() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const deleteDataParameters = () => {
|
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);
|
registrationStore.pushAccountData(changeData);
|
||||||
}
|
}
|
||||||
|
|
||||||
const changeInitialArray = () => {
|
const changeInitialArray = () => {
|
||||||
let newArr = [];
|
let newArr = [];
|
||||||
userDataStore.decryptedData.map(elem => {
|
registrationStore.decryptedUserData.map(elem => {
|
||||||
updatedValues.forEach(item => {
|
updatedValues.forEach(item => {
|
||||||
if (elem.label === item.label) {
|
if (elem.label === item.label) {
|
||||||
newArr.push({
|
newArr.push({
|
||||||
@@ -140,7 +139,7 @@ const Profile = observer (() => {
|
|||||||
|
|
||||||
const addDataParameters = () => {
|
const addDataParameters = () => {
|
||||||
addedValues.key = addedValues.label.toLowerCase().split(' ').join('_');
|
addedValues.key = addedValues.label.toLowerCase().split(' ').join('_');
|
||||||
registrationStore.pushAccountData(userDataStore.decryptedData.concat(addedValues));
|
registrationStore.pushAccountData(registrationStore.decryptedUserData.concat(addedValues));
|
||||||
}
|
}
|
||||||
|
|
||||||
const cancelAddPanel = () => {
|
const cancelAddPanel = () => {
|
||||||
@@ -212,7 +211,7 @@ const Profile = observer (() => {
|
|||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
{/* Table */}
|
{/* Table */}
|
||||||
<ProfileTable selectedItems={handleSelectedItems} userData={userDataStore.decryptedData}/>
|
<ProfileTable selectedItems={handleSelectedItems} userData={registrationStore.decryptedUserData}/>
|
||||||
</div>
|
</div>
|
||||||
{/* Left sidebar */}
|
{/* Left sidebar */}
|
||||||
<div>
|
<div>
|
||||||
@@ -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`}>
|
<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>
|
<h2 className="grow text-base font-semibold text-slate-800 truncate mb-2">Summary</h2>
|
||||||
<div className="flex flex-col">
|
<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>
|
<span key={item.label} className="text-sm font-normal text-slate-600 py-3 border-b border-slate-200">{item.label}</span>
|
||||||
))}
|
))}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,13 +1,13 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import {observer} from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
|
|
||||||
import {transactionsStore} from "../../store/transactionsStore";
|
|
||||||
import Sidebar from '../../partials/Sidebar';
|
import Sidebar from '../../partials/Sidebar';
|
||||||
import Header from '../../partials/Header';
|
import Header from '../../partials/Header';
|
||||||
import ValidateTable from "../../partials/validate/ValidateTable";
|
import ValidateTable from "../../partials/validate/ValidateTable";
|
||||||
import ValidatePanel from "../../partials/validate/ValidatePanel";
|
import ValidatePanel from "../../partials/validate/ValidatePanel";
|
||||||
import ValidateRoadMap from "../../partials/validationlog/ValidateRoadMap";
|
import ValidateRoadMap from "../../partials/validationlog/ValidateRoadMap";
|
||||||
import {Link} from "react-router-dom";
|
import {Link} from "react-router-dom";
|
||||||
|
import {registrationStore} from "../../store/store";
|
||||||
|
|
||||||
const Validate = observer(()=>{
|
const Validate = observer(()=>{
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||||
@@ -58,7 +58,7 @@ const Validate = observer(()=>{
|
|||||||
<div className="pb-8 border-b border-zinc-200 mt-[50px]">
|
<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>
|
<h1 className="text-2xl md:text-3xl text-slate-800 font-bold">Digital ID validation log ✨</h1>
|
||||||
</div>
|
</div>
|
||||||
{transactionsStore.transactionsData.map(item => {
|
{registrationStore.transactionsInfo.map(item => {
|
||||||
return <ValidateRoadMap season={item} key={item.id}/>
|
return <ValidateRoadMap season={item} key={item.id}/>
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
import React, {useState} from 'react';
|
import React, {useState} from 'react';
|
||||||
|
|
||||||
import ValidateRoadMap from "../../partials/validationlog/ValidateRoadMap";
|
import ValidateRoadMap from "../../partials/validationlog/ValidateRoadMap";
|
||||||
import {transactionsStore} from "../../store/transactionsStore";
|
|
||||||
import {observer} from "mobx-react-lite";
|
import {observer} from "mobx-react-lite";
|
||||||
import Sidebar from '../../partials/Sidebar';
|
import Sidebar from '../../partials/Sidebar';
|
||||||
import Header from '../../partials/Header';
|
import Header from '../../partials/Header';
|
||||||
|
import {registrationStore} from "../../store/store";
|
||||||
|
|
||||||
const ValidationLog = observer(()=>{
|
const ValidationLog = observer(()=>{
|
||||||
const [sidebarOpen, setSidebarOpen] = useState(false);
|
const [sidebarOpen, setSidebarOpen] = useState(false);
|
||||||
@@ -28,7 +28,7 @@ const ValidationLog = observer(()=>{
|
|||||||
<div className="max-w-3xl m-auto mt-6">
|
<div className="max-w-3xl m-auto mt-6">
|
||||||
<div className="xl:-translate-x-16 max-w-fit">
|
<div className="xl:-translate-x-16 max-w-fit">
|
||||||
{/* PostsID */}
|
{/* PostsID */}
|
||||||
{transactionsStore.transactionsData.map(item=>{
|
{registrationStore.transactionsInfo.map(item=>{
|
||||||
return <ValidateRoadMap season={item} key={item.id}/>
|
return <ValidateRoadMap season={item} key={item.id}/>
|
||||||
})}
|
})}
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import React, { useState } from 'react';
|
import React, { useState } from 'react';
|
||||||
import Sidebar from '../../partials/Sidebar';
|
import Sidebar from '../../partials/Sidebar';
|
||||||
import Header from '../../partials/Header';
|
import Header from '../../partials/Header';
|
||||||
import { sharedDataStore } from '../../store/sharedDataStore';
|
import {registrationStore} from "../../store/store";
|
||||||
import { observer } from 'mobx-react-lite';
|
import { observer } from 'mobx-react-lite';
|
||||||
|
|
||||||
const Verify = observer(() => {
|
const Verify = observer(() => {
|
||||||
@@ -42,7 +42,7 @@ const Verify = observer(() => {
|
|||||||
</div>
|
</div>
|
||||||
{/* Block */}
|
{/* Block */}
|
||||||
<div className="flex flex-col gap-y-4">
|
<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)]">
|
<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 */}
|
{/* Header */}
|
||||||
<div className="flex justify-end items-center h-[42px]">
|
<div className="flex justify-end items-center h-[42px]">
|
||||||
|
|||||||
27
src/shared/labelMap.js
Normal file
27
src/shared/labelMap.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
export const labelMap = {
|
||||||
|
firstname: 'First name',
|
||||||
|
secondname: 'Second name',
|
||||||
|
gender: "Gender",
|
||||||
|
birthdate: "Birthdate",
|
||||||
|
placeofbirth: "Place of birth",
|
||||||
|
nationality: "Nationality",
|
||||||
|
nationalid: "National ID",
|
||||||
|
nationaldoctype: "National doctype",
|
||||||
|
nationaldocid: "National doc ID",
|
||||||
|
nationaldocissuedate: "National doc issue date",
|
||||||
|
nationaldocexpirydate: "National doc expiry date",
|
||||||
|
telephone: "Telephone",
|
||||||
|
twitter: "Twitter",
|
||||||
|
facebook: "Facebook",
|
||||||
|
instagram: "Instagram",
|
||||||
|
youtube: "Youtube",
|
||||||
|
wechat: "Wechat",
|
||||||
|
tiktok: "Tiktok",
|
||||||
|
linkedin: "Linkedin",
|
||||||
|
vk: "Vk",
|
||||||
|
github: "Github",
|
||||||
|
telegram: "Telegram",
|
||||||
|
qq: "Qq",
|
||||||
|
snapchat: "Snapchat",
|
||||||
|
reddit: "Reddit"
|
||||||
|
};
|
||||||
@@ -1,66 +0,0 @@
|
|||||||
import { makeAutoObservable, reaction } from "mobx";
|
|
||||||
import { fetchWrapper } from "../shared/fetchWrapper";
|
|
||||||
import { registrationStore } from './store';
|
|
||||||
|
|
||||||
const labelMap = {
|
|
||||||
firstname: 'First name',
|
|
||||||
secondname: 'Second name',
|
|
||||||
gender: "Gender",
|
|
||||||
birthdate: "Birthdate",
|
|
||||||
placeofbirth: "Place of birth",
|
|
||||||
nationality: "Nationality",
|
|
||||||
nationalid: "National ID",
|
|
||||||
nationaldoctype: "National doctype",
|
|
||||||
nationaldocid: "National doc ID",
|
|
||||||
nationaldocissuedate: "National doc issue date",
|
|
||||||
nationaldocexpirydate: "National doc expiry date",
|
|
||||||
telephone: "Telephone",
|
|
||||||
twitter: "Twitter",
|
|
||||||
facebook: "Facebook",
|
|
||||||
instagram: "Instagram",
|
|
||||||
youtube: "Youtube",
|
|
||||||
wechat: "Wechat",
|
|
||||||
tiktok: "Tiktok",
|
|
||||||
linkedin: "Linkedin",
|
|
||||||
vk: "Vk",
|
|
||||||
github: "Github",
|
|
||||||
telegram: "Telegram",
|
|
||||||
qq: "Qq",
|
|
||||||
snapchat: "Snapchat",
|
|
||||||
reddit: "Reddit"
|
|
||||||
};
|
|
||||||
|
|
||||||
class SharedDataStore{
|
|
||||||
_keysArray = [];
|
|
||||||
_sharedData = [];
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
makeAutoObservable(this);
|
|
||||||
|
|
||||||
reaction(() => ({data: registrationStore.keysArray}), ({data}) => {
|
|
||||||
this._keysArray = data;
|
|
||||||
this.fetchSharedData();
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchSharedData() {
|
|
||||||
this._keysArray.forEach((elem) => fetchWrapper.get(`http://3.125.47.101/api/data/shared/${elem}`).then((res) => this.changeSharedData(res)))
|
|
||||||
};
|
|
||||||
|
|
||||||
changeSharedData(incomingData) {
|
|
||||||
this._sharedData.push({
|
|
||||||
data: incomingData.data,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
get sharedData() {
|
|
||||||
return this._sharedData.map(elem => ({
|
|
||||||
data: elem.data.map(item => ({
|
|
||||||
label: labelMap[item.label],
|
|
||||||
value: item.value,
|
|
||||||
}))
|
|
||||||
}));
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
export const sharedDataStore = new SharedDataStore();
|
|
||||||
@@ -1,7 +1,14 @@
|
|||||||
import { reaction, makeAutoObservable } from "mobx";
|
import { reaction, makeAutoObservable, onBecomeObserved, onBecomeUnobserved} from "mobx";
|
||||||
import {cryptography} from "@liskhq/lisk-client";
|
import {cryptography} from "@liskhq/lisk-client";
|
||||||
import {getNodeInfo} from '../api/node';
|
import {getNodeInfo} from '../api/node';
|
||||||
import {fetchWrapper} from '../shared/fetchWrapper';
|
import {fetchWrapper} from '../shared/fetchWrapper';
|
||||||
|
import {labelMap} from "../shared/labelMap";
|
||||||
|
import User08 from "../images/user-28-08.jpg";
|
||||||
|
import User06 from "../images/user-28-06.jpg";
|
||||||
|
import User05 from "../images/user-28-05.jpg";
|
||||||
|
import User09 from "../images/user-28-09.jpg";
|
||||||
|
|
||||||
|
const usersImages = [User08,User06,User05,User09];
|
||||||
|
|
||||||
class Store {
|
class Store {
|
||||||
_accountData = []
|
_accountData = []
|
||||||
@@ -10,27 +17,26 @@ class Store {
|
|||||||
|
|
||||||
_nodeInfo = {}
|
_nodeInfo = {}
|
||||||
|
|
||||||
_userData = {}
|
_userData = []
|
||||||
|
|
||||||
_keysArray = []
|
_keysArray = []
|
||||||
|
|
||||||
_transactionsInfo = {}
|
_sharedData = []
|
||||||
|
|
||||||
|
_transactionsInfo = []
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
makeAutoObservable(this);
|
makeAutoObservable(this);
|
||||||
|
|
||||||
this.fetchNodeInfo()
|
this.fetchNodeInfo()
|
||||||
|
|
||||||
reaction(() => this.tokenKey, () => this.getData())
|
reaction(()=>this.keysArray, ()=>this.fetchSharedData())
|
||||||
reaction(() => this.tokenKey, () => this.fetchNewAccountData())
|
onBecomeObserved(this, "userData", () => this.fetchNewAccountData())
|
||||||
reaction(() => this.tokenKey, () => this.fetchTransactionsInfo())
|
onBecomeObserved(this, "transactionsInfo", ()=>this.fetchTransactionsInfo())
|
||||||
|
onBecomeUnobserved(this, "transactionsInfo", ()=>this.unobservedTransactionsInfo())
|
||||||
|
onBecomeObserved(this, "sharedData", ()=>this.fetchKeysArray())
|
||||||
};
|
};
|
||||||
|
|
||||||
getData() {
|
|
||||||
this.fetchNewAccountData();
|
|
||||||
this.fetchKeysArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
fetchNewAccountData() {
|
fetchNewAccountData() {
|
||||||
fetchWrapper.getAuth('http://3.125.47.101/api/data/private', {
|
fetchWrapper.getAuth('http://3.125.47.101/api/data/private', {
|
||||||
networkIdentifier: this.nodeInfo.networkIdentifier,
|
networkIdentifier: this.nodeInfo.networkIdentifier,
|
||||||
@@ -63,18 +69,24 @@ class Store {
|
|||||||
.then((res)=>this.saveInfoTransactions(res))
|
.then((res)=>this.saveInfoTransactions(res))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fetchSharedData() {
|
||||||
|
this._keysArray.forEach((elem) => fetchWrapper.get(`http://3.125.47.101/api/data/shared/${elem}`).then((res) => this.changeSharedData(res)))
|
||||||
|
};
|
||||||
|
|
||||||
|
unobservedTransactionsInfo() {
|
||||||
|
this._transactionsInfo=[]
|
||||||
|
}
|
||||||
|
|
||||||
|
changeSharedData(incomingData) {
|
||||||
|
this._sharedData.push({
|
||||||
|
data: incomingData.data,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
get accountMadeTransaction() {
|
get accountMadeTransaction() {
|
||||||
return "b444b7ff3118cf2a30cbd54cfcdb8fd5d805017a"
|
return "b444b7ff3118cf2a30cbd54cfcdb8fd5d805017a"
|
||||||
}
|
}
|
||||||
|
|
||||||
userDataFetchChange(res) {
|
|
||||||
this._userData = res;
|
|
||||||
}
|
|
||||||
|
|
||||||
keysArrayFetchChange(res) {
|
|
||||||
this._keysArray = res.data;
|
|
||||||
}
|
|
||||||
|
|
||||||
get keysArray() {
|
get keysArray() {
|
||||||
return this._keysArray;
|
return this._keysArray;
|
||||||
}
|
}
|
||||||
@@ -83,10 +95,6 @@ class Store {
|
|||||||
return this._userData;
|
return this._userData;
|
||||||
}
|
}
|
||||||
|
|
||||||
get transactionsInfo() {
|
|
||||||
return this._transactionsInfo
|
|
||||||
}
|
|
||||||
|
|
||||||
savePassPhrase(phrase) {
|
savePassPhrase(phrase) {
|
||||||
this._passPhrase = phrase
|
this._passPhrase = phrase
|
||||||
}
|
}
|
||||||
@@ -96,7 +104,15 @@ class Store {
|
|||||||
};
|
};
|
||||||
|
|
||||||
saveInfoTransactions(transaction) {
|
saveInfoTransactions(transaction) {
|
||||||
this._transactionsInfo = transaction
|
this._transactionsInfo = transaction.data
|
||||||
|
}
|
||||||
|
|
||||||
|
userDataFetchChange(res) {
|
||||||
|
this._userData = res.data;
|
||||||
|
}
|
||||||
|
|
||||||
|
keysArrayFetchChange(res) {
|
||||||
|
this._keysArray = res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
fetchNodeInfo() {
|
fetchNodeInfo() {
|
||||||
@@ -121,6 +137,46 @@ class Store {
|
|||||||
return this._accountData
|
return this._accountData
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get sharedData() {
|
||||||
|
return this._sharedData.map(elem => ({
|
||||||
|
data: elem.data.map(item => ({
|
||||||
|
label: labelMap[item.label],
|
||||||
|
value: item.value,
|
||||||
|
}))
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
||||||
|
get transactionsInfo() {
|
||||||
|
return this._transactionsInfo.map(item=>{
|
||||||
|
return {
|
||||||
|
id: item.id,
|
||||||
|
users_images: usersImages.map(image=>{
|
||||||
|
return {
|
||||||
|
image: image,
|
||||||
|
size: 24
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
transaction: item.asset.features.map(asset=>{
|
||||||
|
return {
|
||||||
|
transaction_id: item.id,
|
||||||
|
address: this.accountMadeTransaction,
|
||||||
|
value: asset.value,
|
||||||
|
label: labelMap[asset.label],
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
get decryptedUserData(){
|
||||||
|
return this._userData.map((elem) => ({
|
||||||
|
...elem,
|
||||||
|
key: elem.label,
|
||||||
|
label: labelMap[elem.label],
|
||||||
|
value: cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, registrationStore.passPhrase, registrationStore.pubKey).split(':')[1]
|
||||||
|
}))
|
||||||
|
}
|
||||||
|
|
||||||
encryptAccountData(data) {
|
encryptAccountData(data) {
|
||||||
return data.map((item) => {
|
return data.map((item) => {
|
||||||
let value = cryptography.encryptMessageWithPassphrase(cryptography.getRandomBytes(32).toString('hex') + ":" + item.value, this.passPhrase, this.pubKey);
|
let value = cryptography.encryptMessageWithPassphrase(cryptography.getRandomBytes(32).toString('hex') + ":" + item.value, this.passPhrase, this.pubKey);
|
||||||
|
|||||||
@@ -1,51 +0,0 @@
|
|||||||
import {makeAutoObservable, reaction} from "mobx";
|
|
||||||
import {registrationStore} from "./store";
|
|
||||||
import User05 from "../../src/images/user-28-05.jpg";
|
|
||||||
import User08 from "../../src/images/user-28-08.jpg";
|
|
||||||
import User09 from "../../src/images/user-28-09.jpg";
|
|
||||||
import User06 from "../../src/images/user-28-06.jpg";
|
|
||||||
|
|
||||||
const labelMap = {
|
|
||||||
firstname: 'First name',
|
|
||||||
secondname: 'Second name',
|
|
||||||
gender: "Gender",
|
|
||||||
birthdate: "Birthdate"
|
|
||||||
};
|
|
||||||
|
|
||||||
const usersImages = [User08,User06,User05,User09];
|
|
||||||
|
|
||||||
class TransactionsStore {
|
|
||||||
_transactionsData = [];
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
makeAutoObservable(this)
|
|
||||||
|
|
||||||
reaction(() => ({data: registrationStore.transactionsInfo}), ({data}) => {
|
|
||||||
this._transactionsData = data.data;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
get transactionsData() {
|
|
||||||
return this._transactionsData.map(item=>{
|
|
||||||
return {
|
|
||||||
id: item.id,
|
|
||||||
users_images: usersImages.map(image=>{
|
|
||||||
return {
|
|
||||||
image: image,
|
|
||||||
size: 24
|
|
||||||
}
|
|
||||||
}),
|
|
||||||
transaction: item.asset.features.map(asset=>{
|
|
||||||
return {
|
|
||||||
transaction_id: item.id,
|
|
||||||
address: registrationStore.accountMadeTransaction,
|
|
||||||
value: asset.value,
|
|
||||||
label: labelMap[asset.label],
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const transactionsStore = new TransactionsStore()
|
|
||||||
@@ -1,53 +0,0 @@
|
|||||||
import { cryptography } from "@liskhq/lisk-client";
|
|
||||||
import { makeAutoObservable, reaction } from "mobx";
|
|
||||||
import { registrationStore } from './store';
|
|
||||||
|
|
||||||
const labelMap = {
|
|
||||||
first_name: 'First name',
|
|
||||||
second_name: 'Second name',
|
|
||||||
gender: "Gender",
|
|
||||||
birthdate: "Birthdate",
|
|
||||||
place_of_birth: "Place of birth",
|
|
||||||
nationality: "Nationality",
|
|
||||||
national_id: "National ID",
|
|
||||||
national_doctype: "National doctype",
|
|
||||||
national_doc_id: "National doc ID",
|
|
||||||
national_doc_issue_date: "National doc issue date",
|
|
||||||
national_doc_expiry_date: "National doc expiry date",
|
|
||||||
telephone: "Telephone",
|
|
||||||
twitter: "Twitter",
|
|
||||||
facebook: "Facebook",
|
|
||||||
instagram: "Instagram",
|
|
||||||
youtube: "Youtube",
|
|
||||||
wechat: "Wechat",
|
|
||||||
tiktok: "Tiktok",
|
|
||||||
linkedin: "Linkedin",
|
|
||||||
vk: "Vk",
|
|
||||||
github: "Github",
|
|
||||||
telegram: "Telegram",
|
|
||||||
qq: "Qq",
|
|
||||||
snapchat: "Snapchat",
|
|
||||||
reddit: "Reddit"
|
|
||||||
};
|
|
||||||
|
|
||||||
class UserDataStore{
|
|
||||||
_data = [];
|
|
||||||
|
|
||||||
constructor() {
|
|
||||||
makeAutoObservable(this);
|
|
||||||
|
|
||||||
reaction(() => ({data: registrationStore.userData}), ({data}) => {
|
|
||||||
this._data = data.data;
|
|
||||||
})
|
|
||||||
}
|
|
||||||
get decryptedData(){
|
|
||||||
return this._data.map((elem) => ({
|
|
||||||
...elem,
|
|
||||||
key: elem.label,
|
|
||||||
label: labelMap[elem.label],
|
|
||||||
value: cryptography.decryptMessageWithPassphrase(elem.value, elem.value_nonce, registrationStore.passPhrase, registrationStore.pubKey).split(':')[1]
|
|
||||||
}))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
export const userDataStore = new UserDataStore();
|
|
||||||
Reference in New Issue
Block a user