diff --git a/src/common/WalletGauge.tsx b/src/common/WalletGauge.tsx index d85408ed..89d7703a 100644 --- a/src/common/WalletGauge.tsx +++ b/src/common/WalletGauge.tsx @@ -217,7 +217,7 @@ export default function WalletGauge(props: Props) {

Transfer successful, waiting for the transaction to be finalized.

Note that this may take up to 30 seconds. If you want to proceed, you can safely - click on cancel but your transaction may not show up yet.

+ click on close but your transaction may not show up yet.

} diff --git a/src/components/identity/IdentityLocRequestDetails.css b/src/components/identity/IdentityLocRequestDetails.css deleted file mode 100644 index 6eed17c5..00000000 --- a/src/components/identity/IdentityLocRequestDetails.css +++ /dev/null @@ -1,5 +0,0 @@ -.Frame .IdentityLocRequestDetails .title { - margin-top: 20px; - margin-left: 10px; - margin-bottom: 20px; -} diff --git a/src/components/identity/IdentityLocRequestDetails.test.tsx b/src/components/identity/IdentityLocRequestDetails.test.tsx deleted file mode 100644 index 28cd9f1e..00000000 --- a/src/components/identity/IdentityLocRequestDetails.test.tsx +++ /dev/null @@ -1,17 +0,0 @@ -import { shallowRender } from '../../tests'; -import { DEFAULT_IDENTITY, DEFAULT_ADDRESS } from "../../common/TestData"; -import { mockValidPolkadotAccountId } from 'src/__mocks__/LogionMock'; -import IdentityLocRequestDetails from "./IdentityLocRequestDetails"; -import { PersonalInfoProps } from './type'; - -test("renders", () => { - const request: PersonalInfoProps = { - requesterAddress: mockValidPolkadotAccountId("5Ew3MyB15VprZrjQVkpQFj8okmc9xLDSEdNhqMMS5cXsqxoW"), - userIdentity: DEFAULT_IDENTITY, - userPostalAddress: DEFAULT_ADDRESS, - }; - const tree = shallowRender(); - expect(tree).toMatchSnapshot(); -}); diff --git a/src/components/identity/IdentityLocRequestDetails.tsx b/src/components/identity/IdentityLocRequestDetails.tsx deleted file mode 100644 index 83dbc244..00000000 --- a/src/components/identity/IdentityLocRequestDetails.tsx +++ /dev/null @@ -1,93 +0,0 @@ -import { Col, Row } from "../../common/Grid"; -import Detail from "../../common/Detail"; -import { PersonalInfoProps } from "./type"; -import LegalEntity from "./LegalEntity"; - -import "./IdentityLocRequestDetails.css"; - -export default function IdentityLocRequestDetails(props: { personalInfo: PersonalInfoProps }) { - - const userIdentity = props.personalInfo.userIdentity || { - firstName: "", - lastName: "", - email: "", - phoneNumber: "", - } - const userPostalAddress = props.personalInfo.userPostalAddress || { - line1: "", - line2: "", - postalCode: "", - city: "", - country: "", - } - return ( - <> - -

Identity data (not publicly available) submitted by the following account address: { props.personalInfo.requesterAddress?.address || "" }

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -} diff --git a/src/components/identity/__snapshots__/IdentityLocRequestDetails.test.tsx.snap b/src/components/identity/__snapshots__/IdentityLocRequestDetails.test.tsx.snap deleted file mode 100644 index bed2e09e..00000000 --- a/src/components/identity/__snapshots__/IdentityLocRequestDetails.test.tsx.snap +++ /dev/null @@ -1,100 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` - - -

- Identity data (not publicly available) submitted by the following account address: - - 5Ew3MyB15VprZrjQVkpQFj8okmc9xLDSEdNhqMMS5cXsqxoW - -

- - - - - - - - - - - - - - - - - - - - - - - - - - - -
-`; diff --git a/src/wallet-user/LocCreation.tsx b/src/components/locrequest/LocRequestButton.tsx similarity index 85% rename from src/wallet-user/LocCreation.tsx rename to src/components/locrequest/LocRequestButton.tsx index 37f97729..ad346f08 100644 --- a/src/wallet-user/LocCreation.tsx +++ b/src/components/locrequest/LocRequestButton.tsx @@ -1,7 +1,7 @@ import { useCallback } from 'react'; import { useNavigate } from "react-router-dom"; -import { requestLocPath } from "./UserRouter"; -import Button from '../common/Button'; +import { requestLocPath } from "../../wallet-user/UserPaths"; +import Button from '../../common/Button'; import { LocType } from "@logion/node-api"; export interface Props { @@ -10,7 +10,7 @@ export interface Props { locType: LocType; } -export default function LocCreation(props: Props) { +export default function LocRequestButton(props: Props) { const { locType } = props; const navigate = useNavigate(); diff --git a/src/legal-officer/ContextualizedWallet.test.tsx b/src/legal-officer/LegalOfficerDashboard.test.tsx similarity index 83% rename from src/legal-officer/ContextualizedWallet.test.tsx rename to src/legal-officer/LegalOfficerDashboard.test.tsx index a92da1dd..5f6534f3 100644 --- a/src/legal-officer/ContextualizedWallet.test.tsx +++ b/src/legal-officer/LegalOfficerDashboard.test.tsx @@ -1,7 +1,7 @@ jest.mock("../logion-chain"); jest.mock("../common/CommonContext"); -import ContextualizedWallet from './ContextualizedWallet'; +import LegalOfficerDashboard from './LegalOfficerDashboard'; import { DEFAULT_LEGAL_OFFICER } from "../common/TestData"; import { shallowRender, mockAccount } from '../tests'; import { setContextMock } from '../logion-chain/__mocks__/LogionChainMock'; @@ -14,6 +14,6 @@ test('renders', () => { ] }); setCurrentAddress(DEFAULT_LEGAL_OFFICER_ACCOUNT); - const tree = shallowRender(); + const tree = shallowRender(); expect(tree).toMatchSnapshot(); }); diff --git a/src/legal-officer/ContextualizedWallet.tsx b/src/legal-officer/LegalOfficerDashboard.tsx similarity index 99% rename from src/legal-officer/ContextualizedWallet.tsx rename to src/legal-officer/LegalOfficerDashboard.tsx index 12970c3f..d7133fa4 100644 --- a/src/legal-officer/ContextualizedWallet.tsx +++ b/src/legal-officer/LegalOfficerDashboard.tsx @@ -22,7 +22,7 @@ import { useLogionChain } from '../logion-chain'; import WarningDialog from 'src/common/WarningDialog'; import { MenuItemData } from 'src/common/MenuItem'; -export default function ContextualizedWallet() { +export default function LegalOfficerDashboard() { const { accounts } = useLogionChain(); const { colorTheme, refresh, availableLegalOfficers, backendConfig } = useCommonContext(); const { refreshRequests, missingSettings, refreshLocs, refreshVotes } = useLegalOfficerContext(); diff --git a/src/legal-officer/LegalOfficerRouter.tsx b/src/legal-officer/LegalOfficerRouter.tsx index a1d699c2..373a8157 100644 --- a/src/legal-officer/LegalOfficerRouter.tsx +++ b/src/legal-officer/LegalOfficerRouter.tsx @@ -21,10 +21,10 @@ import { INVITED_CONTRIBUTORS_RELATIVE_PATH, } from './LegalOfficerPaths'; -import Home from './Home'; -import RecoveryRequests from './RecoveryRequests'; +import Home from './home/Home'; +import RecoveryRequests from './recovery/RecoveryRequests'; import Settings from '../settings/Settings'; -import RecoveryDetails from "./RecoveryDetails"; +import RecoveryDetails from "./recovery/RecoveryDetails"; import Transactions from "../common/Transactions"; import LocDetails, { VoterLocDetails } from "../loc/LocDetails"; import IdentityProtection from './transaction-protection/IdentityProtection'; diff --git a/src/legal-officer/LocIdFormGroup.tsx b/src/legal-officer/LocIdFormGroup.tsx deleted file mode 100644 index d7a99c0b..00000000 --- a/src/legal-officer/LocIdFormGroup.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import { useCallback, useState } from 'react'; -import { Form } from 'react-bootstrap'; -import { LocType, UUID, ValidAccountId } from '@logion/node-api'; - -import Alert from '../common/Alert'; -import { BackgroundAndForegroundColors } from '../common/ColorTheme'; -import FormGroup from '../common/FormGroup'; - -import { useLogionChain } from '../logion-chain'; - -export interface Props { - colors: BackgroundAndForegroundColors; - onChange: (locId: UUID) => void; - expect: { - closed: boolean, - type: LocType, - requester: ValidAccountId, - }; -} - -export default function LocIdFormGroup(props: Props) { - const { api } = useLogionChain(); - const [ locId, setLocId ] = useState(""); - const [ invalidLocIdFeedback, setInvalidLocIdFeedback ] = useState("Given string is not a valid LOC ID"); - - const onChange = useCallback((locId: string) => { - setLocId(locId); - const uuid = UUID.fromAnyString(locId); - if(uuid === undefined) { - setInvalidLocIdFeedback("Given string is not a valid LOC ID"); - } else { - api!.queries.getLegalOfficerCase(uuid) - .then(loc => { - if(loc === undefined) { - setInvalidLocIdFeedback("No LOC with given ID"); - } else if(loc.locType !== props.expect.type) { - setInvalidLocIdFeedback("Given LOC has not expected type"); - } else if(loc.closed !== props.expect.closed) { - setInvalidLocIdFeedback("Given LOC is not in expected state"); - } else if(loc.requesterAddress?.toKey() !== props.expect.requester.toKey()) { - setInvalidLocIdFeedback("Given LOC has not expected requester"); - } else { - setInvalidLocIdFeedback(undefined); - props.onChange(uuid); - } - }); - } - }, [ api, props ]); - - let label; - if(props.expect.closed && props.expect.type === 'Transaction') { - label = "Closed Transaction LOC ID"; - } else if(!props.expect.closed && props.expect.type === 'Transaction') { - label = "Open Transaction LOC ID"; - } else if(props.expect.closed && props.expect.type === 'Identity') { - label = "Closed Identity LOC ID"; - } else if(!props.expect.closed && props.expect.type === 'Identity') { - label = "Open Identity LOC ID"; - } else { - label = "??? Unsupported expect ???"; - } - - return ( - <> - - In order to accept the request, you need to link it to a closed Identity LOC having the - protection requester as subject. - - onChange(e.target.value) } - value={ locId } - isInvalid={ invalidLocIdFeedback !== undefined } - /> } - feedback={ invalidLocIdFeedback } - /> - - ); -} diff --git a/src/legal-officer/Main.tsx b/src/legal-officer/Main.tsx index b2a9e385..693ac4e2 100644 --- a/src/legal-officer/Main.tsx +++ b/src/legal-officer/Main.tsx @@ -1,7 +1,7 @@ import { useLogionChain } from '../logion-chain'; import { LegalOfficerContextProvider } from './LegalOfficerContext'; -import ContextualizedWallet from './ContextualizedWallet'; +import LegalOfficerDashboard from './LegalOfficerDashboard'; export default function LegalOfficerWallet() { const { injectedAccounts } = useLogionChain(); @@ -12,7 +12,7 @@ export default function LegalOfficerWallet() { return ( - + ); } diff --git a/src/legal-officer/PendingProtectionRequests.tsx b/src/legal-officer/PendingProtectionRequests.tsx deleted file mode 100644 index 598ecdb1..00000000 --- a/src/legal-officer/PendingProtectionRequests.tsx +++ /dev/null @@ -1,282 +0,0 @@ -import { useState, useCallback } from 'react'; -import { useNavigate } from "react-router-dom"; -import { ProtectionRequest } from '@logion/client/dist/RecoveryClient.js'; -import ButtonGroup from 'react-bootstrap/ButtonGroup'; -import Form from 'react-bootstrap/Form'; - -import Button from '../common/Button'; -import Table, { Column, Cell, EmptyTableMessage, DateTimeCell, CopyPasteCell } from '../common/Table'; -import { useCommonContext } from '../common/CommonContext'; - -import { useLegalOfficerContext } from './LegalOfficerContext'; -import { acceptProtectionRequest, rejectProtectionRequest } from '../loc/Model'; -import ProcessStep from '../common/ProcessStep'; -import ProtectionRequestStatus from './ProtectionRequestStatus'; -import ProtectionRequestDetails from './ProtectionRequestDetails'; -import { recoveryDetailsPath } from "./LegalOfficerPaths"; -import AccountInfo from "../common/AccountInfo"; -import { useLogionChain } from '../logion-chain'; - -enum ReviewStatus { - NONE, - PENDING, - REJECTING, -} - -interface ReviewState { - status: ReviewStatus, - request?: ProtectionRequest, -} - -const NO_REVIEW_STATE = { status: ReviewStatus.NONE }; - -export interface Props { - recovery: boolean, -} - -export default function PendingProtectionRequests(props: Props) { - const { api, accounts, axiosFactory } = useLogionChain(); - const { colorTheme } = useCommonContext(); - const { pendingProtectionRequests, refreshRequests, pendingRecoveryRequests } = useLegalOfficerContext(); - const [ rejectReason, setRejectReason ] = useState(""); - const [ reviewState, setReviewState ] = useState(NO_REVIEW_STATE); - const navigate = useNavigate(); - - const handleClose = useCallback(() => { - setReviewState(NO_REVIEW_STATE); - }, [ setReviewState ]); - - const rejectAndCloseModal = useCallback(() => { - const currentAddress = accounts!.current!.accountId.address; - (async function() { - const requestId = reviewState.request!.id; - await rejectProtectionRequest(axiosFactory!(currentAddress)!, { - legalOfficerAddress: currentAddress, - requestId, - rejectReason, - }); - setReviewState(NO_REVIEW_STATE); - refreshRequests!(false); - })(); - }, [ axiosFactory, reviewState, accounts, rejectReason, setReviewState, refreshRequests ]); - - const acceptAndCloseModal = useCallback(async () => { - const currentAddress = accounts!.current!.accountId.address; - const requestId = reviewState.request!.id; - await acceptProtectionRequest(axiosFactory!(currentAddress)!, { requestId }); - setReviewState(NO_REVIEW_STATE); - refreshRequests!(false); - }, [ axiosFactory, reviewState, accounts, setReviewState, refreshRequests ]); - - if (!api || pendingProtectionRequests === null || pendingRecoveryRequests === null) { - return null; - } - - let requests; - let columns: Column[]; - if(props.recovery) { - requests = pendingRecoveryRequests; - columns = [ - { - header: "First name", - render: request => , - width: "200px", - align: 'left', - }, - { - header: "Last name", - render: request => , - width: "200px", - renderDetails: request => , - align: 'left', - }, - { - header: "Status", - render: request => , - width: "140px", - splitAfter: true, - }, - { - header: "Submission date", - render: request => , - width: "120px", - }, - { - header: "Account number", - render: request => , - align: 'left', - }, - { - header: "Account to recover", - render: request => , - align: 'left', - }, - { - header: "Action", - render: request => ( - - {!props.recovery && - - } - {props.recovery && - - } - - ), - } - ]; - } else { - requests = pendingProtectionRequests; - columns = [ - { - header: "First name", - render: request => , - width: "200px", - align: 'left', - }, - { - header: "Last name", - render: request => , - width: "200px", - renderDetails: request => , - align: 'left', - }, - { - header: "Status", - render: request => , - width: "140px", - splitAfter: true, - }, - { - header: "Submission date", - render: request => , - width: "120px", - }, - { - header: "Account number", - render: request => , - align: 'left', - }, - { - header: "Action", - render: request => ( - - {!props.recovery && - - } - {props.recovery && - - } - - ), - } - ]; - } - - return ( - <> - No request to display} - /> - - { - reviewState.status === ReviewStatus.PENDING && - setReviewState({ ...reviewState, status: ReviewStatus.REJECTING }), - mayProceed: true, - buttonVariant: "secondary", - buttonText: "No", - }, - { - id: "accept", - mayProceed: true, - buttonVariant: "primary", - buttonText: "Yes", - callback: acceptAndCloseModal, - } - ] } - > - -

I executed my due diligence and accept to be the Legal Officer of this user

-
- } - { - reviewState.status === ReviewStatus.REJECTING && - - - Reason - setRejectReason(e.target.value) } - value={ rejectReason } - data-testid="reason" - /> - - - } - - ); -} diff --git a/src/legal-officer/ProtectedUserDetails.tsx b/src/legal-officer/ProtectedUserDetails.tsx deleted file mode 100644 index 4cdbb678..00000000 --- a/src/legal-officer/ProtectedUserDetails.tsx +++ /dev/null @@ -1,81 +0,0 @@ -import { ProtectionRequest } from '@logion/client/dist/RecoveryClient.js'; - -import { Col } from '../common/Grid'; -import Detail from "../common/Detail"; - -import CopyPasteButton from "../common/CopyPasteButton"; -import { LegalOfficerPostalAddressInfo } from "../common/LegalOfficerPostalAddressInfo"; -import { useLogionChain } from '../logion-chain'; - -export interface Props { - request : ProtectionRequest, -} - -export default function ProtectedUserDetails(props: Props) { - const { getOfficer } = useLogionChain(); - - if(getOfficer === undefined) { - return null; - } - - const legalOfficer = getOfficer(props.request.otherLegalOfficerAddress); - - let userAddress; - if(props.request.userPostalAddress.line2 === null || props.request.userPostalAddress.line2 === "") { - userAddress = { props.request.userPostalAddress.line1 } - } else { - userAddress = { props.request.userPostalAddress.line1 }
{ props.request.userPostalAddress.line2 }
- } - - const polkadotAddress = (address: string) => - { address } - - } - />; - - return ( - <> - - { polkadotAddress(props.request.requesterAddress) } - - - - - - - - - - { polkadotAddress(props.request.otherLegalOfficerAddress) } - } - /> - -   - - ); -} diff --git a/src/legal-officer/ProtectedUsers.test.tsx b/src/legal-officer/ProtectedUsers.test.tsx deleted file mode 100644 index d1d2b114..00000000 --- a/src/legal-officer/ProtectedUsers.test.tsx +++ /dev/null @@ -1,19 +0,0 @@ -jest.mock("../common/CommonContext"); -jest.mock('./LegalOfficerContext'); - -import ProtectedUsers from "./ProtectedUsers"; -import { shallowRender } from '../tests'; -import { setActivatedProtectionRequests } from "./__mocks__/LegalOfficerContextMock"; -import { ACTIVATED_PROTECTION_REQUEST1, ACTIVATED_PROTECTION_REQUEST3 } from "../wallet-user/trust-protection/TestData"; - -test('renders one row', () => { - setActivatedProtectionRequests([ ACTIVATED_PROTECTION_REQUEST1 ]); - const tree = shallowRender(); - expect(tree).toMatchSnapshot(); -}); - -test('renders 2 rows', () => { - setActivatedProtectionRequests([ ACTIVATED_PROTECTION_REQUEST1, ACTIVATED_PROTECTION_REQUEST3 ]); - const tree = shallowRender(); - expect(tree).toMatchSnapshot(); -}); diff --git a/src/legal-officer/ProtectedUsers.tsx b/src/legal-officer/ProtectedUsers.tsx deleted file mode 100644 index 2005a17d..00000000 --- a/src/legal-officer/ProtectedUsers.tsx +++ /dev/null @@ -1,44 +0,0 @@ -import { useLegalOfficerContext } from "./LegalOfficerContext"; -import Table, { Cell, EmptyTableMessage } from '../common/Table'; -import LegalOfficerName from '../common/LegalOfficerNameCell'; -import ProtectedUserDetails from "./ProtectedUserDetails"; -import Button from "../common/Button"; -import { identityLocDetailsPath } from "./LegalOfficerPaths"; -import { useNavigate } from "react-router-dom"; - -export default function ProtectedUsers() { - const { activatedProtectionRequests } = useLegalOfficerContext(); - const navigate = useNavigate(); - - if(activatedProtectionRequests === null) { - return null; - } - - return ( -
, - align: 'left', - width: "55%", - renderDetails: request => , - }, - { - header: "Other Legal Officer", - render: request => , - width: "45%", - align: 'left', - }, - { - header: "Action", - render: request => , - width: "200px", - align: 'center', - }, - ]} - data={ activatedProtectionRequests } - renderEmpty={ () => No user to display } - /> - ); -} diff --git a/src/legal-officer/__snapshots__/ContextualizedWallet.test.tsx.snap b/src/legal-officer/__snapshots__/LegalOfficerDashboard.test.tsx.snap similarity index 100% rename from src/legal-officer/__snapshots__/ContextualizedWallet.test.tsx.snap rename to src/legal-officer/__snapshots__/LegalOfficerDashboard.test.tsx.snap diff --git a/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap b/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap index a0ab5d79..ba1bedc4 100644 --- a/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap +++ b/src/legal-officer/__snapshots__/LegalOfficerRouter.test.tsx.snap @@ -181,7 +181,7 @@ exports[`renders 1`] = ` path="/loc/:locType/:locId/records/:recordId/claims/:hash" /> } + element={} path="" /> - + `; diff --git a/src/legal-officer/__snapshots__/ProtectedUsers.test.tsx.snap b/src/legal-officer/__snapshots__/ProtectedUsers.test.tsx.snap deleted file mode 100644 index 0402770d..00000000 --- a/src/legal-officer/__snapshots__/ProtectedUsers.test.tsx.snap +++ /dev/null @@ -1,151 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 2 rows 1`] = ` -
-`; - -exports[`renders one row 1`] = ` -
-`; diff --git a/src/legal-officer/Home.css b/src/legal-officer/home/Home.css similarity index 100% rename from src/legal-officer/Home.css rename to src/legal-officer/home/Home.css diff --git a/src/legal-officer/Home.test.tsx b/src/legal-officer/home/Home.test.tsx similarity index 57% rename from src/legal-officer/Home.test.tsx rename to src/legal-officer/home/Home.test.tsx index 0c7f1d4e..4cd414e1 100644 --- a/src/legal-officer/Home.test.tsx +++ b/src/legal-officer/home/Home.test.tsx @@ -1,12 +1,12 @@ jest.mock("react-router"); -jest.mock("../common/CommonContext"); -jest.mock("../logion-chain"); -jest.mock('./LegalOfficerContext'); +jest.mock("../../common/CommonContext"); +jest.mock("../../logion-chain"); +jest.mock('../LegalOfficerContext'); import { BalanceState } from "@logion/client/dist/Balance.js"; -import { DEFAULT_COIN_BALANCE, DEFAULT_TRANSACTION } from "../common/TestData"; -import { setBalanceState, } from "../common/__mocks__/CommonContextMock"; -import { shallowRender } from "../tests"; +import { DEFAULT_COIN_BALANCE, DEFAULT_TRANSACTION } from "../../common/TestData"; +import { setBalanceState, } from "../../common/__mocks__/CommonContextMock"; +import { shallowRender } from "../../tests"; import Home from "./Home"; describe("Home", () => { diff --git a/src/legal-officer/Home.tsx b/src/legal-officer/home/Home.tsx similarity index 93% rename from src/legal-officer/Home.tsx rename to src/legal-officer/home/Home.tsx index a6f3e940..29ad5f79 100644 --- a/src/legal-officer/Home.tsx +++ b/src/legal-officer/home/Home.tsx @@ -1,36 +1,36 @@ import { Col, Row } from 'react-bootstrap'; import { useNavigate } from 'react-router'; import { Lgnt } from '@logion/node-api'; -import { useLegalOfficerContext } from "./LegalOfficerContext"; -import { useCommonContext } from "../common/CommonContext"; -import { FullWidthPane } from '../common/Dashboard'; -import Icon from '../common/Icon'; -import Frame from '../common/Frame'; -import Loader from '../common/Loader'; -import Table, { ActionCell, Cell, DateCell, DateTimeCell, EmptyTableMessage } from '../common/Table'; -import TransferAmountCell, { transferBalance } from '../common/TransferAmountCell'; -import AmountCell from '../common/AmountCell'; -import Reading from '../common/Reading'; -import Button from '../common/Button'; -import LocStatusCell from '../common/LocStatusCell'; -import ButtonGroup from '../common/ButtonGroup'; +import { useLegalOfficerContext } from "../LegalOfficerContext"; +import { useCommonContext } from "../../common/CommonContext"; +import { FullWidthPane } from '../../common/Dashboard'; +import Icon from '../../common/Icon'; +import Frame from '../../common/Frame'; +import Loader from '../../common/Loader'; +import Table, { ActionCell, Cell, DateCell, DateTimeCell, EmptyTableMessage } from '../../common/Table'; +import TransferAmountCell, { transferBalance } from '../../common/TransferAmountCell'; +import AmountCell from '../../common/AmountCell'; +import Reading from '../../common/Reading'; +import Button from '../../common/Button'; +import LocStatusCell from '../../common/LocStatusCell'; +import ButtonGroup from '../../common/ButtonGroup'; -import { VAULT_OUT_REQUESTS_PATH, dataLocDetailsPath, identityLocDetailsPath, locDetailsPath, locRequestsPath, transactionsPath } from './LegalOfficerPaths'; +import { VAULT_OUT_REQUESTS_PATH, dataLocDetailsPath, identityLocDetailsPath, locDetailsPath, locRequestsPath, transactionsPath } from '../LegalOfficerPaths'; import './Home.css'; -import UserIdentityNameCell from '../common/UserIdentityNameCell'; -import { TransactionStatusCell } from "../common/TransactionStatusCell"; -import { useLogionChain } from '../logion-chain'; -import TransactionType from 'src/common/TransactionType'; +import UserIdentityNameCell from '../../common/UserIdentityNameCell'; +import { TransactionStatusCell } from "../../common/TransactionStatusCell"; +import { useLogionChain } from '../../logion-chain'; +import TransactionType from '../../common/TransactionType'; import { toFeesClass } from "@logion/client/dist/Fees.js"; -import VaultTransferRequestDetails from './vault/VaultTransferDetails'; -import VaultTransferRequestStatusCell from 'src/common/VaultTransferRequestStatusCell'; -import { useResponsiveContext } from 'src/common/Responsive'; +import VaultTransferRequestDetails from '../vault/VaultTransferDetails'; +import VaultTransferRequestStatusCell from '../../common/VaultTransferRequestStatusCell'; +import { useResponsiveContext } from '../../common/Responsive'; const MAX_WAITING_SHOWN = 3; -export default function Account() { +export default function Home() { const { accounts } = useLogionChain(); const { colorTheme, diff --git a/src/legal-officer/__snapshots__/Home.test.tsx.snap b/src/legal-officer/home/__snapshots__/Home.test.tsx.snap similarity index 100% rename from src/legal-officer/__snapshots__/Home.test.tsx.snap rename to src/legal-officer/home/__snapshots__/Home.test.tsx.snap diff --git a/src/legal-officer/recovery/PendingRecoveryRequests.tsx b/src/legal-officer/recovery/PendingRecoveryRequests.tsx new file mode 100644 index 00000000..533d4558 --- /dev/null +++ b/src/legal-officer/recovery/PendingRecoveryRequests.tsx @@ -0,0 +1,210 @@ +import { useState, useCallback } from 'react'; +import { useNavigate } from "react-router-dom"; +import { ProtectionRequest } from '@logion/client/dist/RecoveryClient.js'; +import ButtonGroup from 'react-bootstrap/ButtonGroup'; +import Form from 'react-bootstrap/Form'; + +import Button from '../../common/Button'; +import Table, { Column, Cell, EmptyTableMessage, DateTimeCell, CopyPasteCell } from '../../common/Table'; +import { useCommonContext } from '../../common/CommonContext'; + +import { useLegalOfficerContext } from '../LegalOfficerContext'; +import { acceptProtectionRequest, rejectProtectionRequest } from '../../loc/Model'; +import ProcessStep from '../../common/ProcessStep'; +import RecoveryRequestStatus from './RecoveryRequestStatus'; +import RecoveryRequestDetails from './RecoveryRequestDetails'; +import { recoveryDetailsPath } from "../LegalOfficerPaths"; +import AccountInfo from "../../common/AccountInfo"; +import { useLogionChain } from '../../logion-chain'; + +enum ReviewStatus { + NONE, + PENDING, + REJECTING, +} + +interface ReviewState { + status: ReviewStatus, + request?: ProtectionRequest, +} + +const NO_REVIEW_STATE = { status: ReviewStatus.NONE }; + +export default function PendingRecoveryRequests() { + const { api, accounts, axiosFactory } = useLogionChain(); + const { colorTheme } = useCommonContext(); + const { refreshRequests, pendingRecoveryRequests } = useLegalOfficerContext(); + const [ rejectReason, setRejectReason ] = useState(""); + const [ reviewState, setReviewState ] = useState(NO_REVIEW_STATE); + const navigate = useNavigate(); + + const handleClose = useCallback(() => { + setReviewState(NO_REVIEW_STATE); + }, [ setReviewState ]); + + const rejectAndCloseModal = useCallback(() => { + const currentAddress = accounts!.current!.accountId.address; + (async function () { + const requestId = reviewState.request!.id; + await rejectProtectionRequest(axiosFactory!(currentAddress)!, { + legalOfficerAddress: currentAddress, + requestId, + rejectReason, + }); + setReviewState(NO_REVIEW_STATE); + refreshRequests!(false); + })(); + }, [ axiosFactory, reviewState, accounts, rejectReason, setReviewState, refreshRequests ]); + + const acceptAndCloseModal = useCallback(async () => { + const currentAddress = accounts!.current!.accountId.address; + const requestId = reviewState.request!.id; + await acceptProtectionRequest(axiosFactory!(currentAddress)!, { requestId }); + setReviewState(NO_REVIEW_STATE); + refreshRequests!(false); + }, [ axiosFactory, reviewState, accounts, setReviewState, refreshRequests ]); + + if (!api || pendingRecoveryRequests === null) { + return null; + } + + let columns: Column[]; + + columns = [ + { + header: "First name", + render: request => , + width: "200px", + align: 'left', + }, + { + header: "Last name", + render: request => , + width: "200px", + renderDetails: request => , + align: 'left', + }, + { + header: "Status", + render: request => , + width: "140px", + splitAfter: true, + }, + { + header: "Submission date", + render: request => , + width: "120px", + }, + { + header: "Account number", + render: request => , + align: 'left', + }, + { + header: "Account to recover", + render: request => , + align: 'left', + }, + { + header: "Action", + render: request => ( + + + + ), + } + ]; + + return ( + <> +
No request to display } + /> + + { + reviewState.status === ReviewStatus.PENDING && + setReviewState({ ...reviewState, status: ReviewStatus.REJECTING }), + mayProceed: true, + buttonVariant: "secondary", + buttonText: "No", + }, + { + id: "accept", + mayProceed: true, + buttonVariant: "primary", + buttonText: "Yes", + callback: acceptAndCloseModal, + } + ] } + > + +

I executed my due diligence and accept to be the Legal Officer of this user

+
+ } + { + reviewState.status === ReviewStatus.REJECTING && + + + Reason + setRejectReason(e.target.value) } + value={ rejectReason } + data-testid="reason" + /> + + + } + + ); +} diff --git a/src/legal-officer/RecoveryDetails.css b/src/legal-officer/recovery/RecoveryDetails.css similarity index 100% rename from src/legal-officer/RecoveryDetails.css rename to src/legal-officer/recovery/RecoveryDetails.css diff --git a/src/legal-officer/RecoveryDetails.test.tsx b/src/legal-officer/recovery/RecoveryDetails.test.tsx similarity index 85% rename from src/legal-officer/RecoveryDetails.test.tsx rename to src/legal-officer/recovery/RecoveryDetails.test.tsx index f4a2e3cb..231a9635 100644 --- a/src/legal-officer/RecoveryDetails.test.tsx +++ b/src/legal-officer/recovery/RecoveryDetails.test.tsx @@ -1,9 +1,9 @@ -jest.mock('../logion-chain/Signature'); -jest.mock("../common/CommonContext"); -jest.mock("../loc/Model"); -jest.mock("./Model"); -jest.mock("./LegalOfficerContext"); -jest.mock("../logion-chain"); +jest.mock('../../logion-chain/Signature'); +jest.mock("../../common/CommonContext"); +jest.mock("../../loc/Model"); +jest.mock("../Model"); +jest.mock("../LegalOfficerContext"); +jest.mock("../../logion-chain"); import { LegalOfficerCase } from "@logion/node-api"; import { SubmittableExtrinsic } from "@polkadot/api-base/types"; @@ -11,15 +11,15 @@ import { render, waitFor, screen } from '@testing-library/react'; import userEvent from '@testing-library/user-event'; import RecoveryDetails from './RecoveryDetails'; -import { RecoveryInfo } from './Types'; -import { acceptProtectionRequest, rejectProtectionRequest } from '../loc/__mocks__/ModelMock'; -import { setFetchRecoveryInfo } from './__mocks__/ModelMock'; -import { PROTECTION_REQUESTS_HISTORY } from './TestData'; -import { axiosMock, setAddresses, DEFAULT_LEGAL_OFFICER_ACCOUNT } from '../logion-chain/__mocks__/LogionChainMock'; -import { setParams, navigate } from '../__mocks__/ReactRouterMock'; -import { refreshRequests } from './__mocks__/LegalOfficerContextMock'; +import { RecoveryInfo } from '../Types'; +import { acceptProtectionRequest, rejectProtectionRequest } from '../../loc/__mocks__/ModelMock'; +import { setFetchRecoveryInfo } from '../__mocks__/ModelMock'; +import { PROTECTION_REQUESTS_HISTORY } from '../TestData'; +import { axiosMock, setAddresses, DEFAULT_LEGAL_OFFICER_ACCOUNT } from '../../logion-chain/__mocks__/LogionChainMock'; +import { setParams, navigate } from '../../__mocks__/ReactRouterMock'; +import { refreshRequests } from '../__mocks__/LegalOfficerContextMock'; import { It, Mock } from 'moq.ts'; -import { mockValidPolkadotAccountId, setupApiMock, CLOSED_IDENTITY_LOC_ID } from 'src/__mocks__/LogionMock'; +import { mockValidPolkadotAccountId, setupApiMock, CLOSED_IDENTITY_LOC_ID } from '../../__mocks__/LogionMock'; describe("RecoveryDetails", () => { diff --git a/src/legal-officer/RecoveryDetails.tsx b/src/legal-officer/recovery/RecoveryDetails.tsx similarity index 91% rename from src/legal-officer/RecoveryDetails.tsx rename to src/legal-officer/recovery/RecoveryDetails.tsx index 5fe716d1..1a2bd366 100644 --- a/src/legal-officer/RecoveryDetails.tsx +++ b/src/legal-officer/recovery/RecoveryDetails.tsx @@ -2,25 +2,25 @@ import { useEffect, useState, useCallback } from "react"; import { Col, Row } from "react-bootstrap"; import Form from 'react-bootstrap/Form'; -import { useCommonContext } from "../common/CommonContext"; -import { useLegalOfficerContext } from "./LegalOfficerContext"; -import { FullWidthPane } from "../common/Dashboard"; +import { useCommonContext } from "../../common/CommonContext"; +import { useLegalOfficerContext } from "../LegalOfficerContext"; +import { FullWidthPane } from "../../common/Dashboard"; import { useParams, useNavigate } from 'react-router'; -import { RECOVERY_REQUESTS_PATH } from "./LegalOfficerPaths"; -import Button from "../common/Button"; -import { acceptProtectionRequest, rejectProtectionRequest } from "../loc/Model"; -import { fetchRecoveryInfo } from "./Model"; -import { RecoveryInfo } from "./Types"; -import AccountInfo from "../common/AccountInfo"; -import Alert from "../common/Alert"; -import Frame from "../common/Frame"; +import { RECOVERY_REQUESTS_PATH } from "../LegalOfficerPaths"; +import Button from "../../common/Button"; +import { acceptProtectionRequest, rejectProtectionRequest } from "../../loc/Model"; +import { fetchRecoveryInfo } from "../Model"; +import { RecoveryInfo } from "../Types"; +import AccountInfo from "../../common/AccountInfo"; +import Alert from "../../common/Alert"; +import Frame from "../../common/Frame"; import "./RecoveryDetails.css" -import Spacer from "../common/Spacer"; -import Icon from "../common/Icon"; -import Dialog from "../common/Dialog"; -import { CallCallback, useLogionChain } from '../logion-chain'; -import ButtonGroup from "../common/ButtonGroup"; -import ExtrinsicSubmissionStateView from 'src/ExtrinsicSubmissionStateView'; +import Spacer from "../../common/Spacer"; +import Icon from "../../common/Icon"; +import Dialog from "../../common/Dialog"; +import { CallCallback, useLogionChain } from '../../logion-chain'; +import ButtonGroup from "../../common/ButtonGroup"; +import ExtrinsicSubmissionStateView from '../../ExtrinsicSubmissionStateView'; enum Visible { NONE, diff --git a/src/legal-officer/ProtectionRequestDetails.tsx b/src/legal-officer/recovery/RecoveryRequestDetails.tsx similarity index 90% rename from src/legal-officer/ProtectionRequestDetails.tsx rename to src/legal-officer/recovery/RecoveryRequestDetails.tsx index 492de842..785ddeb3 100644 --- a/src/legal-officer/ProtectionRequestDetails.tsx +++ b/src/legal-officer/recovery/RecoveryRequestDetails.tsx @@ -1,13 +1,13 @@ import { ProtectionRequest } from '@logion/client/dist/RecoveryClient.js'; -import { Col } from '../common/Grid'; -import Detail from "../common/Detail"; +import { Col } from '../../common/Grid'; +import Detail from "../../common/Detail"; export interface ProtectionRequestDetailsProps { request : ProtectionRequest, } -export default function ProtectionRequestDetails(props: ProtectionRequestDetailsProps) { +export default function RecoveryRequestDetails(props: ProtectionRequestDetailsProps) { return ( <> diff --git a/src/legal-officer/ProtectionRequestStatus.css b/src/legal-officer/recovery/RecoveryRequestStatus.css similarity index 82% rename from src/legal-officer/ProtectionRequestStatus.css rename to src/legal-officer/recovery/RecoveryRequestStatus.css index 83714ea3..5bf84a24 100644 --- a/src/legal-officer/ProtectionRequestStatus.css +++ b/src/legal-officer/recovery/RecoveryRequestStatus.css @@ -1,4 +1,4 @@ -.ProtectionRequestStatus { +.RecoveryRequestStatus { display: inline-block; padding: 10px; border: 1px solid white; diff --git a/src/legal-officer/ProtectionRequestStatus.tsx b/src/legal-officer/recovery/RecoveryRequestStatus.tsx similarity index 86% rename from src/legal-officer/ProtectionRequestStatus.tsx rename to src/legal-officer/recovery/RecoveryRequestStatus.tsx index 0f0a31af..c8457a3f 100644 --- a/src/legal-officer/ProtectionRequestStatus.tsx +++ b/src/legal-officer/recovery/RecoveryRequestStatus.tsx @@ -1,15 +1,15 @@ import { ProtectionRequestStatus as ProtectionRequestStatusType } from '@logion/client/dist/RecoveryClient.js'; -import Icon from "../common/Icon"; -import { ORANGE, GREEN, RED, YELLOW } from "../common/ColorTheme"; +import Icon from "../../common/Icon"; +import { ORANGE, GREEN, RED, YELLOW } from "../../common/ColorTheme"; -import './ProtectionRequestStatus.css'; +import './RecoveryRequestStatus.css'; export interface Props { status: ProtectionRequestStatusType, } -export default function ProtectionRequestStatus(props: Props) { +export default function RecoveryRequestStatus(props: Props) { let icon; let status; @@ -41,7 +41,7 @@ export default function ProtectionRequestStatus(props: Props) { return ( { const tree = shallowRender(); diff --git a/src/legal-officer/RecoveryRequests.tsx b/src/legal-officer/recovery/RecoveryRequests.tsx similarity index 79% rename from src/legal-officer/RecoveryRequests.tsx rename to src/legal-officer/recovery/RecoveryRequests.tsx index 8abf17f3..142a655c 100644 --- a/src/legal-officer/RecoveryRequests.tsx +++ b/src/legal-officer/recovery/RecoveryRequests.tsx @@ -1,13 +1,13 @@ import { useState } from 'react'; import { useLocation } from 'react-router-dom'; -import Tabs from '../common/Tabs'; -import { FullWidthPane } from '../common/Dashboard'; +import Tabs from '../../common/Tabs'; +import { FullWidthPane } from '../../common/Dashboard'; -import PendingProtectionRequests from './PendingProtectionRequests'; +import PendingRecoveryRequests from './PendingRecoveryRequests'; import RecoveryRequestsHistory from './RecoveryRequestsHistory'; import './RecoveryRequests.css'; -import { getQueryParam } from '../common/QueryString'; +import { getQueryParam } from '../../common/QueryString'; export default function RecoveryRequests() { const location = useLocation(); @@ -31,7 +31,7 @@ export default function RecoveryRequests() { { key: "pending", title: "Pending", - render: () => + render: () => }, { key: "history", diff --git a/src/legal-officer/RecoveryRequestsHistory.test.tsx b/src/legal-officer/recovery/RecoveryRequestsHistory.test.tsx similarity index 62% rename from src/legal-officer/RecoveryRequestsHistory.test.tsx rename to src/legal-officer/recovery/RecoveryRequestsHistory.test.tsx index c06513cf..6878736c 100644 --- a/src/legal-officer/RecoveryRequestsHistory.test.tsx +++ b/src/legal-officer/recovery/RecoveryRequestsHistory.test.tsx @@ -1,10 +1,10 @@ -jest.mock('./LegalOfficerContext'); -jest.mock('./Model'); +jest.mock('../LegalOfficerContext'); +jest.mock('../Model'); -import { shallowRender } from '../tests'; +import { shallowRender } from '../../tests'; import RecoveryRequestsHistory from './RecoveryRequestsHistory'; -import { setRecoveryRequestsHistory } from './__mocks__/LegalOfficerContextMock'; -import { RECOVERY_REQUESTS_HISTORY } from './TestData'; +import { setRecoveryRequestsHistory } from '../__mocks__/LegalOfficerContextMock'; +import { RECOVERY_REQUESTS_HISTORY } from '../TestData'; test("Renders null with no data", () => { const tree = shallowRender(); diff --git a/src/legal-officer/RecoveryRequestsHistory.tsx b/src/legal-officer/recovery/RecoveryRequestsHistory.tsx similarity index 82% rename from src/legal-officer/RecoveryRequestsHistory.tsx rename to src/legal-officer/recovery/RecoveryRequestsHistory.tsx index 2daf05ec..d1979637 100644 --- a/src/legal-officer/RecoveryRequestsHistory.tsx +++ b/src/legal-officer/recovery/RecoveryRequestsHistory.tsx @@ -1,8 +1,8 @@ -import Table, { Cell, EmptyTableMessage, DateTimeCell, CopyPasteCell } from '../common/Table'; +import Table, { Cell, EmptyTableMessage, DateTimeCell, CopyPasteCell } from '../../common/Table'; -import { useLegalOfficerContext } from './LegalOfficerContext'; -import ProtectionRequestStatus from './ProtectionRequestStatus'; -import ProtectionRequestDetails from './ProtectionRequestDetails'; +import { useLegalOfficerContext } from '../LegalOfficerContext'; +import RecoveryRequestStatus from './RecoveryRequestStatus'; +import RecoveryRequestDetails from './RecoveryRequestDetails'; export default function RecoveryRequestsHistory() { @@ -26,12 +26,12 @@ export default function RecoveryRequestsHistory() { header: "Last name", render: request => , width: "200px", - renderDetails: request => , + renderDetails: request => , align: 'left', }, { header: "Status", - render: request => , + render: request => , width: "170px", splitAfter: true, }, diff --git a/src/legal-officer/__snapshots__/RecoveryRequests.test.tsx.snap b/src/legal-officer/recovery/__snapshots__/RecoveryRequests.test.tsx.snap similarity index 100% rename from src/legal-officer/__snapshots__/RecoveryRequests.test.tsx.snap rename to src/legal-officer/recovery/__snapshots__/RecoveryRequests.test.tsx.snap diff --git a/src/legal-officer/__snapshots__/RecoveryRequestsHistory.test.tsx.snap b/src/legal-officer/recovery/__snapshots__/RecoveryRequestsHistory.test.tsx.snap similarity index 100% rename from src/legal-officer/__snapshots__/RecoveryRequestsHistory.test.tsx.snap rename to src/legal-officer/recovery/__snapshots__/RecoveryRequestsHistory.test.tsx.snap diff --git a/src/legal-officer/transaction-protection/LocRequestDetails.tsx b/src/legal-officer/transaction-protection/LocRequestDetails.tsx deleted file mode 100644 index 8c3b47c1..00000000 --- a/src/legal-officer/transaction-protection/LocRequestDetails.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { LocData } from "@logion/client"; - -import TransactionLocRequestDetails from "./TransactionLocRequestDetails"; -import IdentityLocRequestDetails from "../../components/identity/IdentityLocRequestDetails"; - -export interface LocRequestDetailsProps { - request: LocData, -} - -export default function LocRequestDetails(props: LocRequestDetailsProps) { - - const { request } = props; - - if (request.locType === "Identity") { - return - } else { - return - } -} diff --git a/src/legal-officer/transaction-protection/TransactionLocRequestDetails.test.tsx b/src/legal-officer/transaction-protection/TransactionLocRequestDetails.test.tsx deleted file mode 100644 index 91a1d373..00000000 --- a/src/legal-officer/transaction-protection/TransactionLocRequestDetails.test.tsx +++ /dev/null @@ -1,19 +0,0 @@ -import { LocData } from '@logion/client'; -import { shallowRender } from '../../tests'; -import TransactionLocRequestDetails from './TransactionLocRequestDetails'; -import { mockValidPolkadotAccountId } from 'src/__mocks__/LogionMock'; - -test("renders", () => { - const request = { - id: "1", - ownerAddress: "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY", - requesterAddress: mockValidPolkadotAccountId("5Ew3MyB15VprZrjQVkpQFj8okmc9xLDSEdNhqMMS5cXsqxoW"), - description: "LOC description", - status: "OPEN", - createdOn: "2021-09-24T13:30:00.000", - } as unknown as LocData; - const tree = shallowRender(); - expect(tree).toMatchSnapshot(); -}); diff --git a/src/legal-officer/transaction-protection/TransactionLocRequestDetails.tsx b/src/legal-officer/transaction-protection/TransactionLocRequestDetails.tsx deleted file mode 100644 index e167e22d..00000000 --- a/src/legal-officer/transaction-protection/TransactionLocRequestDetails.tsx +++ /dev/null @@ -1,35 +0,0 @@ -import { Col } from '../../common/Grid'; -import Detail from "../../common/Detail"; -import { LocRequestDetailsProps } from "./LocRequestDetails"; - -export default function TransactionLocRequestDetails(props: LocRequestDetailsProps) { - - return ( - <> - - - - - - - - - - - ); -} diff --git a/src/legal-officer/transaction-protection/__snapshots__/TransactionLocRequestDetails.test.tsx.snap b/src/legal-officer/transaction-protection/__snapshots__/TransactionLocRequestDetails.test.tsx.snap deleted file mode 100644 index d653dc95..00000000 --- a/src/legal-officer/transaction-protection/__snapshots__/TransactionLocRequestDetails.test.tsx.snap +++ /dev/null @@ -1,42 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`renders 1`] = ` - - - - - - - - - - - -`; diff --git a/src/loc/CollectionLocRequestForm.tsx b/src/loc/CollectionLocRequestForm.tsx index 18333421..921fb26f 100644 --- a/src/loc/CollectionLocRequestForm.tsx +++ b/src/loc/CollectionLocRequestForm.tsx @@ -12,7 +12,7 @@ import { useUserContext } from "../wallet-user/UserContext"; import ButtonGroup from "../common/ButtonGroup"; import Button from "../common/Button"; import { useLogionChain } from "../logion-chain"; -import { locDetailsPath } from "../wallet-user/UserRouter"; +import { locDetailsPath } from "../wallet-user/UserPaths"; import { useNavigate } from "react-router"; export interface FormValues { diff --git a/src/loc/DataLocRequest.tsx b/src/loc/DataLocRequest.tsx index 5d457254..ee1cdca7 100644 --- a/src/loc/DataLocRequest.tsx +++ b/src/loc/DataLocRequest.tsx @@ -1,6 +1,6 @@ import { FullWidthPane } from "../common/Dashboard"; import Frame from "../common/Frame"; -import SelectLegalOfficer from "../wallet-user/trust-protection/SelectLegalOfficer"; +import SelectLegalOfficer from "../wallet-user/protection/SelectLegalOfficer"; import { Row, Col } from "react-bootstrap"; import { useNavigate } from "react-router"; import { useState, useMemo } from "react"; @@ -8,7 +8,7 @@ import { LegalOfficerClass } from "@logion/client"; import { useUserContext } from "../wallet-user/UserContext"; import { useCommonContext } from "../common/CommonContext"; import CollectionLocRequestForm from "./CollectionLocRequestForm"; -import LocCreation from "../wallet-user/LocCreation"; +import LocRequestButton from "../components/locrequest/LocRequestButton"; import "./DataLocRequest.css"; import ButtonGroup from "../common/ButtonGroup"; import TransactionLocRequestForm from "./TransactionLocRequestForm"; @@ -63,7 +63,7 @@ export default function DataLocRequest(props: Props) { please request an Identity LOC to the Logion Legal Officer of your choice by clicking on the related button below:

- + } @@ -74,7 +74,7 @@ export default function DataLocRequest(props: Props) {

Please request an Identity LOC to the Logion Legal Officer of your choice:

- + } diff --git a/src/loc/DocumentClaimHistory.tsx b/src/loc/DocumentClaimHistory.tsx index 6a2c4a07..d23d90f1 100644 --- a/src/loc/DocumentClaimHistory.tsx +++ b/src/loc/DocumentClaimHistory.tsx @@ -9,7 +9,7 @@ import CheckDeliveredFrame from "src/components/deliverycheck/CheckDeliveredFram import ItemFiles, { DeliveredFile } from "src/components/itemfiles/ItemFiles"; import { locDetailsPath, tokensRecordPath } from "src/legal-officer/LegalOfficerPaths"; import { useLogionChain } from "src/logion-chain"; -import { locDetailsPath as userLocDetailsPath, tokensRecordPath as requesterTokensRecordPath, issuerTokensRecordPath } from "src/wallet-user/UserRouter"; +import { locDetailsPath as userLocDetailsPath, tokensRecordPath as requesterTokensRecordPath, issuerTokensRecordPath } from "src/wallet-user/UserPaths"; import { CheckLatestDeliveryResponse, getAllCollectionFileDeliveries, getTokensRecordDeliveries, getTokensRecordFileSource } from "./FileModel"; import { LegalOfficerLocContextProvider } from "./LegalOfficerLocContext"; import { useLocContext } from "./LocContext"; diff --git a/src/loc/IdenfyVerification.tsx b/src/loc/IdenfyVerification.tsx index 20d69ca7..d59f87ed 100644 --- a/src/loc/IdenfyVerification.tsx +++ b/src/loc/IdenfyVerification.tsx @@ -3,7 +3,7 @@ import { useCallback } from "react"; import Button from "src/common/Button"; import Frame from "src/common/Frame"; import { useLocContext } from "./LocContext"; -import { resumeAfterIDenfyProcessUrl } from "../wallet-user/UserRouter"; +import { resumeAfterIDenfyProcessUrl } from "../wallet-user/UserPaths"; export default function IdenfyVerification() { const { loc, mutateLocState } = useLocContext(); diff --git a/src/wallet-user/trust-protection/IdentityLocRequest.css b/src/loc/IdentityLocRequest.css similarity index 100% rename from src/wallet-user/trust-protection/IdentityLocRequest.css rename to src/loc/IdentityLocRequest.css diff --git a/src/wallet-user/trust-protection/IdentityLocRequest.test.tsx b/src/loc/IdentityLocRequest.test.tsx similarity index 88% rename from src/wallet-user/trust-protection/IdentityLocRequest.test.tsx rename to src/loc/IdentityLocRequest.test.tsx index 6c78a459..6429b27c 100644 --- a/src/wallet-user/trust-protection/IdentityLocRequest.test.tsx +++ b/src/loc/IdentityLocRequest.test.tsx @@ -3,16 +3,16 @@ import { DraftRequest, LocsState } from "@logion/client"; import { render, waitFor, screen, getByText } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; -import { GUILLAUME, oneLegalOfficer } from "../../common/TestData"; -import { shallowRender, clickByName } from "../../tests"; +import { GUILLAUME, oneLegalOfficer } from "../common/TestData"; +import { shallowRender, clickByName } from "../tests"; import IdentityLocRequest from "./IdentityLocRequest"; -import { fillInForm } from "../../components/identity/IdentityFormTestHelper"; -import { setMutateLocsState, setHasValidIdentityLoc, setLocsState } from "../__mocks__/UserContextMock"; -import { navigate, setSearchParams } from 'src/__mocks__/ReactRouterMock'; +import { fillInForm } from "../components/identity/IdentityFormTestHelper"; +import { setMutateLocsState, setHasValidIdentityLoc, setLocsState } from "../wallet-user/__mocks__/UserContextMock"; +import { navigate, setSearchParams } from '../__mocks__/ReactRouterMock'; -jest.mock('../UserContext'); -jest.mock('../../logion-chain'); -jest.mock('../../common/CommonContext'); +jest.mock('../wallet-user/UserContext'); +jest.mock('../logion-chain'); +jest.mock('../common/CommonContext'); describe("IdentityLocRequest", () => { diff --git a/src/wallet-user/trust-protection/IdentityLocRequest.tsx b/src/loc/IdentityLocRequest.tsx similarity index 94% rename from src/wallet-user/trust-protection/IdentityLocRequest.tsx rename to src/loc/IdentityLocRequest.tsx index f2edab60..3649b6a3 100644 --- a/src/wallet-user/trust-protection/IdentityLocRequest.tsx +++ b/src/loc/IdentityLocRequest.tsx @@ -1,22 +1,22 @@ -import Button from "../../common/Button"; +import Button from "../common/Button"; import { useState, useCallback, useMemo } from "react"; -import IdentityForm, { FormValues } from "../../components/identity/IdentityForm"; +import IdentityForm, { FormValues } from "../components/identity/IdentityForm"; import { useForm } from "react-hook-form"; -import { useCommonContext } from "../../common/CommonContext"; -import SelectLegalOfficer from "./SelectLegalOfficer"; +import { useCommonContext } from "../common/CommonContext"; +import SelectLegalOfficer from "../wallet-user/protection/SelectLegalOfficer"; import { LegalOfficerClass, LocsState, UserIdentity, PostalAddress, DraftRequest } from "@logion/client"; -import { useUserContext } from "../UserContext"; +import { useUserContext } from "../wallet-user/UserContext"; import Form from "react-bootstrap/Form"; -import Frame from "../../common/Frame"; -import { useLogionChain } from "../../logion-chain"; -import { FullWidthPane } from "../../common/Dashboard"; +import Frame from "../common/Frame"; +import { useLogionChain } from "../logion-chain"; +import { FullWidthPane } from "../common/Dashboard"; import { useNavigate } from "react-router"; import { Row, Col } from "react-bootstrap"; -import FormGroup from "src/common/FormGroup"; +import FormGroup from "../common/FormGroup"; import './IdentityLocRequest.css'; -import { locDetailsPath } from "../UserRouter"; -import IconTextRow from "src/common/IconTextRow"; -import Icon from "src/common/Icon"; +import { locDetailsPath } from "../wallet-user/UserPaths"; +import IconTextRow from "../common/IconTextRow"; +import Icon from "../common/Icon"; import { UUID } from "@logion/node-api"; export interface Props { diff --git a/src/loc/LocDetails.tsx b/src/loc/LocDetails.tsx index 48df7038..3284a93c 100644 --- a/src/loc/LocDetails.tsx +++ b/src/loc/LocDetails.tsx @@ -44,11 +44,6 @@ export function UserLocDetails(props: UserLocDetailsProps) { ) } -export interface VoterLocDetailsProps { - backPath: string; - detailsPath: (locId: UUID, type: LocType) => string; -} - export function VoterLocDetails(props: LocDetailsProps) { const locId: UUID = new UUID(useParams<"locId">().locId); return ( diff --git a/src/loc/LocItem.tsx b/src/loc/LocItem.tsx index 5a579876..68de6c01 100644 --- a/src/loc/LocItem.tsx +++ b/src/loc/LocItem.tsx @@ -24,7 +24,7 @@ import { Child } from "src/common/types/Helpers"; import ViewFileButton from "src/common/ViewFileButton"; import { documentClaimHistoryPath } from "src/legal-officer/LegalOfficerPaths"; import { fullCertificateUrl } from "src/PublicPaths"; -import { documentClaimHistoryPath as userDocumentClaimHistoryPath } from "src/wallet-user/UserRouter"; +import { documentClaimHistoryPath as userDocumentClaimHistoryPath } from "src/wallet-user/UserPaths"; import LocLinkDetails from "./LocLinkDetails"; import LocPrivateFileDetails from "./LocPrivateFileDetails"; import LocPublicDataDetails from "./LocPublicDataDetails"; diff --git a/src/loc/TransactionLocRequestForm.tsx b/src/loc/TransactionLocRequestForm.tsx index 34c99cc3..0067ad1c 100644 --- a/src/loc/TransactionLocRequestForm.tsx +++ b/src/loc/TransactionLocRequestForm.tsx @@ -10,7 +10,7 @@ import { DraftRequest, LocsState } from "@logion/client"; import { useUserContext } from "../wallet-user/UserContext"; import ButtonGroup from "../common/ButtonGroup"; import Button from "../common/Button"; -import { locDetailsPath } from "../wallet-user/UserRouter"; +import { locDetailsPath } from "../wallet-user/UserPaths"; import { useNavigate } from "react-router"; export interface FormValues { diff --git a/src/wallet-user/trust-protection/__snapshots__/IdentityLocRequest.test.tsx.snap b/src/loc/__snapshots__/IdentityLocRequest.test.tsx.snap similarity index 100% rename from src/wallet-user/trust-protection/__snapshots__/IdentityLocRequest.test.tsx.snap rename to src/loc/__snapshots__/IdentityLocRequest.test.tsx.snap diff --git a/src/loc/invited-contributor/InvitedContributorsButton.tsx b/src/loc/invited-contributor/InvitedContributorsButton.tsx index e39b4501..28c942df 100644 --- a/src/loc/invited-contributor/InvitedContributorsButton.tsx +++ b/src/loc/invited-contributor/InvitedContributorsButton.tsx @@ -4,7 +4,7 @@ import Button from "src/common/Button"; import { useCommonContext } from "src/common/CommonContext"; import { invitedContributorsPath as legalOfficerInvitedContributorsPath } from "src/legal-officer/LegalOfficerPaths"; import { useLocContext } from "../LocContext"; -import { invitedContributorsPath as requesterInvitedContributorsPath } from "src/wallet-user/UserRouter"; +import { invitedContributorsPath as requesterInvitedContributorsPath } from "src/wallet-user/UserPaths"; export default function InvitedContributorsButton() { const { viewer } = useCommonContext(); diff --git a/src/loc/invited-contributor/InvitedContributorsPane.tsx b/src/loc/invited-contributor/InvitedContributorsPane.tsx index 23f154df..eb9dcafa 100644 --- a/src/loc/invited-contributor/InvitedContributorsPane.tsx +++ b/src/loc/invited-contributor/InvitedContributorsPane.tsx @@ -1,7 +1,7 @@ import { UUID } from "@logion/node-api"; import { useParams } from "react-router-dom"; import { locDetailsPath } from "src/legal-officer/LegalOfficerPaths"; -import { ISSUER_PATH, locDetailsPath as userLocDetailsPath } from "src/wallet-user/UserRouter"; +import { ISSUER_PATH, locDetailsPath as userLocDetailsPath } from "src/wallet-user/UserPaths"; import { LegalOfficerLocContextProvider } from "../LegalOfficerLocContext"; import { useLocContext } from "../LocContext"; import LocPane from "../LocPane"; diff --git a/src/loc/record/TokensRecordButton.tsx b/src/loc/record/TokensRecordButton.tsx index 8130246a..54b60ed8 100644 --- a/src/loc/record/TokensRecordButton.tsx +++ b/src/loc/record/TokensRecordButton.tsx @@ -6,7 +6,7 @@ import Icon from "src/common/Icon"; import { tokensRecordPath } from "src/legal-officer/LegalOfficerPaths"; import { useLocContext } from "../LocContext"; import { ContributionMode } from "../types"; -import { tokensRecordPath as requesterTokensRecordPath, issuerTokensRecordPath } from "src/wallet-user/UserRouter"; +import { tokensRecordPath as requesterTokensRecordPath, issuerTokensRecordPath } from "src/wallet-user/UserPaths"; export default function TokensRecordButton(props: { contributionMode?: ContributionMode }) { const { viewer } = useCommonContext(); diff --git a/src/loc/record/TokensRecordFiles.tsx b/src/loc/record/TokensRecordFiles.tsx index e638438d..83a6dfb8 100644 --- a/src/loc/record/TokensRecordFiles.tsx +++ b/src/loc/record/TokensRecordFiles.tsx @@ -5,7 +5,7 @@ import { tokensRecordDocumentClaimHistoryPath } from "../../legal-officer/LegalO import { tokensRecordDocumentClaimHistoryPath as requesterTokensRecordDocumentClaimHistoryPath, issuerTokensRecordDocumentClaimHistoryPath -} from "../../wallet-user/UserRouter"; +} from "../../wallet-user/UserPaths"; import { useLocContext } from "../LocContext"; import ViewFileButton from "../../common/ViewFileButton"; import { getTokensRecordFileSource } from "../FileModel"; diff --git a/src/loc/record/TokensRecordPane.tsx b/src/loc/record/TokensRecordPane.tsx index 32b0103d..8a4b0454 100644 --- a/src/loc/record/TokensRecordPane.tsx +++ b/src/loc/record/TokensRecordPane.tsx @@ -1,7 +1,7 @@ import { UUID } from "@logion/node-api"; import { useParams } from "react-router-dom"; import { locDetailsPath } from "src/legal-officer/LegalOfficerPaths"; -import { ISSUER_PATH, locDetailsPath as userLocDetailsPath } from "src/wallet-user/UserRouter"; +import { ISSUER_PATH, locDetailsPath as userLocDetailsPath } from "src/wallet-user/UserPaths"; import { LegalOfficerLocContextProvider } from "../LegalOfficerLocContext"; import { useLocContext } from "../LocContext"; import LocPane from "../LocPane"; diff --git a/src/loc/statement/StatementOfFactsRequestButton.tsx b/src/loc/statement/StatementOfFactsRequestButton.tsx index 2402c5d1..2da70f2a 100644 --- a/src/loc/statement/StatementOfFactsRequestButton.tsx +++ b/src/loc/statement/StatementOfFactsRequestButton.tsx @@ -5,7 +5,7 @@ import { useState, useCallback } from "react"; import Button from "../../common/Button"; import { useUserLocContext } from "../UserLocContext"; import Dialog from "../../common/Dialog"; -import { locRequestsPath } from "../../wallet-user/UserRouter"; +import { locRequestsPath } from "../../wallet-user/UserPaths"; type Status = 'Idle' | 'Confirming' | 'Requesting' | 'Requested'; diff --git a/src/vault/VaultOutRequest.tsx b/src/vault/VaultOutRequest.tsx index e9f507d2..7e2803eb 100644 --- a/src/vault/VaultOutRequest.tsx +++ b/src/vault/VaultOutRequest.tsx @@ -13,7 +13,7 @@ import Icon from "../common/Icon"; import Select, { OptionType } from "../common/Select"; import { CallCallback, useLogionChain } from "../logion-chain"; -import { buildOptions } from '../wallet-user/trust-protection/SelectLegalOfficer'; +import { buildOptions } from '../wallet-user/protection/SelectLegalOfficer'; import { useUserContext } from "../wallet-user/UserContext"; import ExtrinsicSubmissionStateView from "src/ExtrinsicSubmissionStateView"; diff --git a/src/wallet-user/Main.tsx b/src/wallet-user/Main.tsx index 9eaa2752..c801658e 100644 --- a/src/wallet-user/Main.tsx +++ b/src/wallet-user/Main.tsx @@ -1,7 +1,7 @@ import { useLogionChain } from '../logion-chain'; import { UserContextProvider } from "./UserContext"; -import ContextualizedWallet from './ContextualizedWallet'; +import UserDashboard from './UserDashboard'; export default function Wallet() { const { allAccounts } = useLogionChain(); @@ -12,7 +12,7 @@ export default function Wallet() { return ( - + ); } diff --git a/src/wallet-user/RefreshRequestsButton.test.tsx b/src/wallet-user/RefreshRequestsButton.test.tsx deleted file mode 100644 index 300e4d45..00000000 --- a/src/wallet-user/RefreshRequestsButton.test.tsx +++ /dev/null @@ -1,18 +0,0 @@ -jest.mock('./UserContext'); - -import RefreshRequestsButton from './RefreshRequestsButton'; -import { shallowRender } from '../tests'; -import { setRefreshRequests } from './__mocks__/UserContextMock'; - -test("Renders null with no data", () => { - setRefreshRequests(null); - const tree = shallowRender(); - expect(tree).toMatchSnapshot(); -}); - -test("Renders with refreshRequests", () => { - const refreshRequests = jest.fn(); - setRefreshRequests(refreshRequests); - const tree = shallowRender(); - expect(tree).toMatchSnapshot(); -}); diff --git a/src/wallet-user/RefreshRequestsButton.tsx b/src/wallet-user/RefreshRequestsButton.tsx deleted file mode 100644 index e0b22162..00000000 --- a/src/wallet-user/RefreshRequestsButton.tsx +++ /dev/null @@ -1,12 +0,0 @@ -import Button from 'react-bootstrap/Button'; - -import { useUserContext } from './UserContext'; - -export default function RefreshRequestsButton() { - const { refreshRequests } = useUserContext(); - if(refreshRequests === null) { - return null; - } else { - return ; - } -} diff --git a/src/wallet-user/ContextualizedWallet.test.tsx b/src/wallet-user/UserDashboard.test.tsx similarity index 80% rename from src/wallet-user/ContextualizedWallet.test.tsx rename to src/wallet-user/UserDashboard.test.tsx index d5daf98e..e9e76053 100644 --- a/src/wallet-user/ContextualizedWallet.test.tsx +++ b/src/wallet-user/UserDashboard.test.tsx @@ -4,13 +4,13 @@ jest.mock('../logion-chain'); jest.mock('../common/CommonContext'); jest.mock('./UserContext'); -import ContextualizedWallet from './ContextualizedWallet'; +import UserDashboard from './UserDashboard'; import { setContextMock } from '../logion-chain/__mocks__/LogionChainMock'; import { shallowRender } from '../tests'; import { LocsState } from "@logion/client"; import { mockValidPolkadotAccountId, api } from 'src/__mocks__/LogionMock'; -describe("ContextualizedWallet", () => { +describe("UserDashboard", () => { setLocsState({} as LocsState) @@ -25,12 +25,12 @@ describe("ContextualizedWallet", () => { } } }); - - const tree = shallowRender(); - + + const tree = shallowRender(); + expect(tree).toMatchSnapshot(); }); - + test('Given connected and account, then renders with router', () => { setContextMock({ api: api.object(), @@ -41,8 +41,8 @@ describe("ContextualizedWallet", () => { } }); - const tree = shallowRender(); - + const tree = shallowRender(); + expect(tree).toMatchSnapshot(); }); @@ -51,9 +51,9 @@ describe("ContextualizedWallet", () => { api: api.object(), accounts: null }); - - const tree = shallowRender(); - + + const tree = shallowRender(); + expect(tree).toMatchSnapshot(); - }); + }); }); diff --git a/src/wallet-user/ContextualizedWallet.tsx b/src/wallet-user/UserDashboard.tsx similarity index 97% rename from src/wallet-user/ContextualizedWallet.tsx rename to src/wallet-user/UserDashboard.tsx index 1283f75e..9510ed11 100644 --- a/src/wallet-user/ContextualizedWallet.tsx +++ b/src/wallet-user/UserDashboard.tsx @@ -4,7 +4,8 @@ import { useLogionChain } from '../logion-chain'; import Dashboard from '../common/Dashboard'; -import UserRouter, { +import UserRouter from "./UserRouter"; +import { HOME_PATH, TRUST_PROTECTION_PATH, SETTINGS_PATH, @@ -13,11 +14,11 @@ import UserRouter, { ISSUER_PATH, transactionsPath, vaultTransactionsPath, -} from "./UserRouter"; +} from "./UserPaths"; import { useUserContext } from "./UserContext"; import { useCommonContext } from '../common/CommonContext'; -export default function ContextualizedWallet() { +export default function UserDashboard() { const { accounts, api } = useLogionChain(); const { colorTheme, refresh } = useCommonContext(); const { refreshRequests, vaultState, locsState } = useUserContext(); diff --git a/src/wallet-user/UserPaths.tsx b/src/wallet-user/UserPaths.tsx new file mode 100644 index 00000000..5b8f4ac7 --- /dev/null +++ b/src/wallet-user/UserPaths.tsx @@ -0,0 +1,125 @@ +import { UUID, LocType, Hash } from '@logion/node-api'; +import { getBaseUrl } from "../PublicPaths"; + +import { + USER_PATH, + locRequestsRelativePath, + locDetailsRelativePath, + LOC_DETAILS_RELATIVE_PATH +} from '../RootPaths'; + +export const HOME_PATH = USER_PATH; +export const TRUST_PROTECTION_RELATIVE_PATH = '/protection'; +export const TRUST_PROTECTION_PATH = USER_PATH + TRUST_PROTECTION_RELATIVE_PATH; +export const SETTINGS_RELATIVE_PATH = '/settings'; +export const SETTINGS_PATH = USER_PATH + SETTINGS_RELATIVE_PATH; +export const RECOVERY_RELATIVE_PATH = '/recovery'; +export const RECOVERY_PATH = USER_PATH + RECOVERY_RELATIVE_PATH; +export const WALLET_RELATIVE_PATH = '/wallet'; +export const VAULT_RELATIVE_PATH = '/vault'; +export const ISSUER_RELATIVE_PATH = '/verified-issuer'; +export const ISSUER_PATH = USER_PATH + ISSUER_RELATIVE_PATH; +export const ISSUER_DETAILS_RELATIVE_PATH = ISSUER_RELATIVE_PATH + '/:locId'; +export const IDENFY_RELATIVE_PATH = '/idenfy'; +export const IDENFY_PATH = USER_PATH + IDENFY_RELATIVE_PATH; +export const REQUEST_LOC_RELATIVE_PATH = '/loc/:locType-request'; + +export function issuerDetailsPath(locId: UUID | string) { + return USER_PATH + ISSUER_DETAILS_RELATIVE_PATH + .replace(":locId", locId.toString()) +} + +export const TRANSACTIONS_RELATIVE_PATH = WALLET_RELATIVE_PATH + '/:coinId'; +const TRANSACTIONS_PATH = USER_PATH + TRANSACTIONS_RELATIVE_PATH; +export function transactionsPath(coinId: string): string { + return TRANSACTIONS_PATH.replace(":coinId", coinId); +} + +export const VAULT_TRANSACTIONS_RELATIVE_PATH = VAULT_RELATIVE_PATH + '/:coinId'; +const VAULT_TRANSACTIONS_PATH = USER_PATH + VAULT_TRANSACTIONS_RELATIVE_PATH; +export function vaultTransactionsPath(coinId: string): string { + return VAULT_TRANSACTIONS_PATH.replace(":coinId", coinId); +} + +export function dataLocDetailsPath(locType: LocType, locId: string) { + return USER_PATH + locDetailsRelativePath(locType) + .replace(":locId", locId) +} + +export function locRequestsPath(locType: LocType) { + return USER_PATH + locRequestsRelativePath(locType) +} + +export function requestLocRelativePath(locType: LocType) { + return REQUEST_LOC_RELATIVE_PATH + .replace(":locType", locType.toLowerCase()) +} + +export function requestLocPath(locType: LocType) { + return USER_PATH + requestLocRelativePath(locType) +} + +export function locDetailsPath(locId: string | UUID, locType: LocType) { + let stringId; + if(locId instanceof UUID) { + stringId = locId.toString(); + } else { + stringId = locId; + } + return dataLocDetailsPath(locType, stringId); +} + +export const PARAM_RESULT = "result"; +export const PARAM_LOC_ID = "locId"; + +export function resumeAfterIDenfyProcessUrl(result: 'success' | 'error' | 'unverified', locId: UUID): string { + return `${ getBaseUrl() }${ IDENFY_PATH }?${ PARAM_RESULT }=${ result }&${ PARAM_LOC_ID }=${ locId.toString() }`; +} + +export const DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/claims/:hash"; +export function documentClaimHistoryPath(locId: UUID, hash: Hash) { + return USER_PATH + DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH + .replace(":locType", "Collection") + .replace(":locId", locId.toString()) + .replace(":hash", hash.toHex()); +} + +export const TOKENS_RECORD_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/records"; +export function tokensRecordPath(locId: UUID) { + return USER_PATH + TOKENS_RECORD_RELATIVE_PATH + .replace(":locType", "Collection") + .replace(":locId", locId.toString()); +} + +export const ISSUER_TOKENS_RECORD_RELATIVE_PATH = ISSUER_DETAILS_RELATIVE_PATH + "/records"; +export function issuerTokensRecordPath(locId: UUID) { + return USER_PATH + ISSUER_TOKENS_RECORD_RELATIVE_PATH + .replace(":locType", "Collection") + .replace(":locId", locId.toString()); +} + +export const TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/records/:recordId/claims/:hash"; +export function tokensRecordDocumentClaimHistoryPath(locId: UUID, recordId: Hash, hash: Hash) { + return USER_PATH + TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH + .replace(":locType", "Collection") + .replace(":locId", locId.toString()) + .replace(":recordId", recordId.toHex()) + .replace(":hash", hash.toHex()); +} + +export const ISSUER_TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH = ISSUER_DETAILS_RELATIVE_PATH + "/records/:recordId/claims/:hash"; +export function issuerTokensRecordDocumentClaimHistoryPath(locId: UUID, recordId: Hash, hash: Hash) { + return USER_PATH + ISSUER_TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH + .replace(":locType", "Collection") + .replace(":locId", locId.toString()) + .replace(":recordId", recordId.toHex()) + .replace(":hash", hash.toHex()); +} + +export const INVITED_CONTRIBUTORS_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/invited-contributors"; +export function invitedContributorsPath(locId: UUID) { + return USER_PATH + INVITED_CONTRIBUTORS_RELATIVE_PATH + .replace(":locType", "collection") + .replace(":locId", locId.toString()); +} + diff --git a/src/wallet-user/UserRouter.tsx b/src/wallet-user/UserRouter.tsx index d311df80..45980439 100644 --- a/src/wallet-user/UserRouter.tsx +++ b/src/wallet-user/UserRouter.tsx @@ -1,154 +1,53 @@ import { Routes, Route } from 'react-router-dom'; -import { UUID, LocType, Hash } from '@logion/node-api'; - +import { UUID, LocType } from '@logion/node-api'; import { - USER_PATH, locRequestsRelativePath, locDetailsRelativePath, relativeDashboardCertificateRelativePath, - LOC_DETAILS_RELATIVE_PATH } from '../RootPaths'; - +import { + TRUST_PROTECTION_RELATIVE_PATH, + SETTINGS_RELATIVE_PATH, + RECOVERY_RELATIVE_PATH, + TRANSACTIONS_RELATIVE_PATH, + VAULT_TRANSACTIONS_RELATIVE_PATH, + SETTINGS_PATH, + locDetailsPath, + locRequestsPath, + requestLocRelativePath, + ISSUER_RELATIVE_PATH, + ISSUER_DETAILS_RELATIVE_PATH, + ISSUER_PATH, + issuerDetailsPath, + IDENFY_RELATIVE_PATH, + DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH, + TOKENS_RECORD_RELATIVE_PATH, + ISSUER_TOKENS_RECORD_RELATIVE_PATH, + TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH, + ISSUER_TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH, + INVITED_CONTRIBUTORS_RELATIVE_PATH +} from "./UserPaths"; import Settings from "../settings/Settings"; import Transactions from "../common/Transactions"; import { UserLocDetails } from '../loc/LocDetails'; import DashboardCertificateRouter from "../loc/DashboardCertificateRouter"; import { useCommonContext } from "../common/CommonContext"; - import { useUserContext } from "./UserContext"; -import Home from "./Home"; -import TrustProtection from "./trust-protection/TrustProtection"; -import Recovery from "./trust-protection/Recovery"; +import Home from "./home/Home"; +import TrustProtection from "./protection/TrustProtection"; +import Recovery from "./recovery/Recovery"; import { useLogionChain } from '../logion-chain'; -import IdentityLocRequest from "./trust-protection/IdentityLocRequest"; +import IdentityLocRequest from "../loc/IdentityLocRequest"; import IssuerDashboard from "./issuer/IssuerDashboard"; -import IdenfyVerificationResult from './IdenfyVerificationResult'; +import IdenfyVerificationResult from './idenfy/IdenfyVerificationResult'; import { UserDocumentClaimHistory, UserTokensRecordDocumentClaimHistory } from 'src/loc/DocumentClaimHistory'; import { UserTokensRecordPane } from 'src/loc/record/TokensRecordPane'; import { Navigate } from 'react-router-dom'; -import { getBaseUrl } from "../PublicPaths"; import { UserInvitedContributorsPane } from "../loc/invited-contributor/InvitedContributorsPane"; import LocsDashboard from 'src/loc/dashboard/LocsDashboard'; -import LocCreation from "./LocCreation"; +import LocRequestButton from "../components/locrequest/LocRequestButton"; import DataLocRequest from "../loc/DataLocRequest"; -export const HOME_PATH = USER_PATH; - -export const TRUST_PROTECTION_RELATIVE_PATH = '/protection'; -export const TRUST_PROTECTION_PATH = USER_PATH + TRUST_PROTECTION_RELATIVE_PATH; -export const SETTINGS_RELATIVE_PATH = '/settings'; -export const SETTINGS_PATH = USER_PATH + SETTINGS_RELATIVE_PATH; -export const RECOVERY_RELATIVE_PATH = '/recovery'; -export const RECOVERY_PATH = USER_PATH + RECOVERY_RELATIVE_PATH; -export const WALLET_RELATIVE_PATH = '/wallet'; -export const VAULT_RELATIVE_PATH = '/vault'; -export const ISSUER_RELATIVE_PATH = '/verified-issuer'; -export const ISSUER_PATH = USER_PATH + ISSUER_RELATIVE_PATH; -export const ISSUER_DETAILS_RELATIVE_PATH = ISSUER_RELATIVE_PATH + '/:locId'; -export const IDENFY_RELATIVE_PATH = '/idenfy'; -export const IDENFY_PATH = USER_PATH + IDENFY_RELATIVE_PATH; - -export function issuerDetailsPath(locId: UUID | string) { - return USER_PATH + ISSUER_DETAILS_RELATIVE_PATH - .replace(":locId", locId.toString()) -} - -export const TRANSACTIONS_RELATIVE_PATH = WALLET_RELATIVE_PATH + '/:coinId'; -const TRANSACTIONS_PATH = USER_PATH + TRANSACTIONS_RELATIVE_PATH; -export function transactionsPath(coinId: string): string { - return TRANSACTIONS_PATH.replace(":coinId", coinId); -} - -export const VAULT_TRANSACTIONS_RELATIVE_PATH = VAULT_RELATIVE_PATH + '/:coinId'; -const VAULT_TRANSACTIONS_PATH = USER_PATH + VAULT_TRANSACTIONS_RELATIVE_PATH; -export function vaultTransactionsPath(coinId: string): string { - return VAULT_TRANSACTIONS_PATH.replace(":coinId", coinId); -} - -export function dataLocDetailsPath(locType: LocType, locId: string) { - return USER_PATH + locDetailsRelativePath(locType) - .replace(":locId", locId) -} - -export function locRequestsPath(locType: LocType) { - return USER_PATH + locRequestsRelativePath(locType) -} - -export const REQUEST_LOC_RELATIVE_PATH = '/loc/:locType-request'; - -function requestLocRelativePath(locType: LocType) { - return REQUEST_LOC_RELATIVE_PATH - .replace(":locType", locType.toLowerCase()) -} - -export function requestLocPath(locType: LocType) { - return USER_PATH + requestLocRelativePath(locType) -} - -export function locDetailsPath(locId: string | UUID, locType: LocType) { - let stringId; - if(locId instanceof UUID) { - stringId = locId.toString(); - } else { - stringId = locId; - } - return dataLocDetailsPath(locType, stringId); -} - -export const PARAM_RESULT = "result"; -export const PARAM_LOC_ID = "locId"; - -export function resumeAfterIDenfyProcessUrl(result: 'success' | 'error' | 'unverified', locId: UUID): string { - return `${ getBaseUrl() }${ IDENFY_PATH }?${ PARAM_RESULT }=${ result }&${ PARAM_LOC_ID }=${ locId.toString() }`; -} - -export const DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/claims/:hash"; -export function documentClaimHistoryPath(locId: UUID, hash: Hash) { - return USER_PATH + DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH - .replace(":locType", "Collection") - .replace(":locId", locId.toString()) - .replace(":hash", hash.toHex()); -} - -export const TOKENS_RECORD_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/records"; -export function tokensRecordPath(locId: UUID) { - return USER_PATH + TOKENS_RECORD_RELATIVE_PATH - .replace(":locType", "Collection") - .replace(":locId", locId.toString()); -} - -export const ISSUER_TOKENS_RECORD_RELATIVE_PATH = ISSUER_DETAILS_RELATIVE_PATH + "/records"; -export function issuerTokensRecordPath(locId: UUID) { - return USER_PATH + ISSUER_TOKENS_RECORD_RELATIVE_PATH - .replace(":locType", "Collection") - .replace(":locId", locId.toString()); -} - -export const TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/records/:recordId/claims/:hash"; -export function tokensRecordDocumentClaimHistoryPath(locId: UUID, recordId: Hash, hash: Hash) { - return USER_PATH + TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH - .replace(":locType", "Collection") - .replace(":locId", locId.toString()) - .replace(":recordId", recordId.toHex()) - .replace(":hash", hash.toHex()); -} - -export const ISSUER_TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH = ISSUER_DETAILS_RELATIVE_PATH + "/records/:recordId/claims/:hash"; -export function issuerTokensRecordDocumentClaimHistoryPath(locId: UUID, recordId: Hash, hash: Hash) { - return USER_PATH + ISSUER_TOKENS_RECORD_DOCUMENT_CLAIM_HISTORY_RELATIVE_PATH - .replace(":locType", "Collection") - .replace(":locId", locId.toString()) - .replace(":recordId", recordId.toHex()) - .replace(":hash", hash.toHex()); -} - -export const INVITED_CONTRIBUTORS_RELATIVE_PATH = LOC_DETAILS_RELATIVE_PATH + "/invited-contributors"; -export function invitedContributorsPath(locId: UUID) { - return USER_PATH + INVITED_CONTRIBUTORS_RELATIVE_PATH - .replace(":locType", "collection") - .replace(":locId", locId.toString()); -} - export default function UserRouter() { const { accounts } = useLogionChain(); const { balanceState } = useCommonContext(); @@ -184,7 +83,7 @@ export default function UserRouter() { element={ } + actions={ } settingsPath={ SETTINGS_PATH } locs={ locs["Transaction"] } loading={ locsState === undefined || locsState.discarded } @@ -196,7 +95,7 @@ export default function UserRouter() { element={ } + actions={ } settingsPath={ SETTINGS_PATH } locs={ locs["Collection"] } loading={ locsState === undefined || locsState.discarded } @@ -208,7 +107,7 @@ export default function UserRouter() { element={ } + actions={ } settingsPath={ SETTINGS_PATH } locs={ locs["Identity"] } loading={ locsState === undefined || locsState.discarded } @@ -259,7 +158,7 @@ export default function UserRouter() { issuerDetailsPath(locId) } + detailsPath={ (locId: UUID, _: LocType) => issuerDetailsPath(locId) } contributionMode='VerifiedIssuer' /> } /> diff --git a/src/wallet-user/__snapshots__/Main.test.tsx.snap b/src/wallet-user/__snapshots__/Main.test.tsx.snap index 45090828..6912c267 100644 --- a/src/wallet-user/__snapshots__/Main.test.tsx.snap +++ b/src/wallet-user/__snapshots__/Main.test.tsx.snap @@ -2,6 +2,6 @@ exports[`renders 1`] = ` - + `; diff --git a/src/wallet-user/__snapshots__/RefreshRequestsButton.test.tsx.snap b/src/wallet-user/__snapshots__/RefreshRequestsButton.test.tsx.snap deleted file mode 100644 index 722229d7..00000000 --- a/src/wallet-user/__snapshots__/RefreshRequestsButton.test.tsx.snap +++ /dev/null @@ -1,14 +0,0 @@ -// Jest Snapshot v1, https://goo.gl/fbAQLP - -exports[`Renders null with no data 1`] = `null`; - -exports[`Renders with refreshRequests 1`] = ` - -`; diff --git a/src/wallet-user/__snapshots__/ContextualizedWallet.test.tsx.snap b/src/wallet-user/__snapshots__/UserDashboard.test.tsx.snap similarity index 96% rename from src/wallet-user/__snapshots__/ContextualizedWallet.test.tsx.snap rename to src/wallet-user/__snapshots__/UserDashboard.test.tsx.snap index 12f0fb15..46e9406f 100644 --- a/src/wallet-user/__snapshots__/ContextualizedWallet.test.tsx.snap +++ b/src/wallet-user/__snapshots__/UserDashboard.test.tsx.snap @@ -1,6 +1,6 @@ // Jest Snapshot v1, https://goo.gl/fbAQLP -exports[`ContextualizedWallet Given connected and account, then renders with router 1`] = ` +exports[`UserDashboard Given connected and account, then renders with router 1`] = ` `; -exports[`ContextualizedWallet Given connected and no account then renders without router 1`] = `null`; +exports[`UserDashboard Given connected and no account then renders without router 1`] = `null`; -exports[`ContextualizedWallet Given disconnected and accounts then empty 1`] = ` +exports[`UserDashboard Given disconnected and accounts then empty 1`] = ` } @@ -70,7 +70,7 @@ exports[`renders 1`] = ` element={ } @@ -96,7 +96,7 @@ exports[`renders 1`] = ` element={ } @@ -159,7 +159,7 @@ exports[`renders 1`] = ` path="/loc/identity/:locId" /> } + element={} path="/" /> { diff --git a/src/wallet-user/Home.tsx b/src/wallet-user/home/Home.tsx similarity index 85% rename from src/wallet-user/Home.tsx rename to src/wallet-user/home/Home.tsx index aea772c4..168eaec2 100644 --- a/src/wallet-user/Home.tsx +++ b/src/wallet-user/home/Home.tsx @@ -2,32 +2,32 @@ import { Col, Row } from 'react-bootstrap'; import { useNavigate } from 'react-router'; import { Lgnt } from '@logion/node-api'; -import { useCommonContext } from "../common/CommonContext"; -import { FullWidthPane } from '../common/Dashboard'; -import Icon from '../common/Icon'; -import Frame from '../common/Frame'; -import Loader from '../common/Loader'; -import Table, { DateCell, EmptyTableMessage } from '../common/Table'; -import TransferAmountCell, { transferBalance } from '../common/TransferAmountCell'; -import AmountCell from '../common/AmountCell'; -import Reading from '../common/Reading'; -import Button from '../common/Button'; -import { TransactionStatusCell } from "../common/TransactionStatusCell"; -import NetworkWarning from '../common/NetworkWarning'; -import { useLogionChain } from '../logion-chain'; +import { useCommonContext } from "../../common/CommonContext"; +import { FullWidthPane } from '../../common/Dashboard'; +import Icon from '../../common/Icon'; +import Frame from '../../common/Frame'; +import Loader from '../../common/Loader'; +import Table, { DateCell, EmptyTableMessage } from '../../common/Table'; +import TransferAmountCell, { transferBalance } from '../../common/TransferAmountCell'; +import AmountCell from '../../common/AmountCell'; +import Reading from '../../common/Reading'; +import Button from '../../common/Button'; +import { TransactionStatusCell } from "../../common/TransactionStatusCell"; +import NetworkWarning from '../../common/NetworkWarning'; +import { useLogionChain } from '../../logion-chain'; -import { SETTINGS_PATH, transactionsPath } from './UserRouter'; +import { SETTINGS_PATH, transactionsPath } from '../UserPaths'; import './Home.css'; -import TransactionType from 'src/common/TransactionType'; -import { useUserContext } from "./UserContext"; -import Shortcut from 'src/components/shortcuts/Shortcut'; -import Shortcuts from 'src/components/shortcuts/Shortcuts'; -import LocCreation from './LocCreation'; +import TransactionType from '../../common/TransactionType'; +import { useUserContext } from "../UserContext"; +import Shortcut from '../../components/shortcuts/Shortcut'; +import Shortcuts from '../../components/shortcuts/Shortcuts'; +import LocRequestButton from '../../components/locrequest/LocRequestButton'; import { useMemo } from 'react'; import { toFeesClass } from "@logion/client/dist/Fees.js"; -export default function Account() { +export default function Home() { const { colorTheme } = useCommonContext(); return ( @@ -140,7 +140,7 @@ export function Content() { What shall logion protect for you? } > - Identity
} />} /> - } /> - string; diff --git a/src/wallet-user/issuer/IssuerClosedLocs.tsx b/src/wallet-user/issuer/IssuerClosedLocs.tsx index 21522a5f..691e6005 100644 --- a/src/wallet-user/issuer/IssuerClosedLocs.tsx +++ b/src/wallet-user/issuer/IssuerClosedLocs.tsx @@ -15,7 +15,7 @@ import { merge } from "./IssuerUtils"; import Icon from "src/common/Icon"; import "./IssuerClosedLocs.css"; import { useNavigate } from "react-router-dom"; -import { issuerTokensRecordPath } from "../UserRouter"; +import { issuerTokensRecordPath } from '../UserPaths'; import { OverlayTrigger, Tooltip } from "react-bootstrap"; export default function IssuerClosedLocs() { diff --git a/src/wallet-user/issuer/IssuerOpenedLocs.tsx b/src/wallet-user/issuer/IssuerOpenedLocs.tsx index f5f03997..18491ca0 100644 --- a/src/wallet-user/issuer/IssuerOpenedLocs.tsx +++ b/src/wallet-user/issuer/IssuerOpenedLocs.tsx @@ -7,7 +7,7 @@ import LegalOfficerName from '../../common/LegalOfficerNameCell'; import ButtonGroup from "../../common/ButtonGroup"; import Button from "../../common/Button"; import Loader from '../../common/Loader'; -import { issuerDetailsPath } from '../UserRouter'; +import { issuerDetailsPath } from '../UserPaths'; import { useResponsiveContext } from '../../common/Responsive'; import UserIdentityNameCell from "../../common/UserIdentityNameCell"; import { LocData } from "@logion/client"; diff --git a/src/wallet-user/trust-protection/CreateProtectionRequestForm.css b/src/wallet-user/protection/CreateProtectionRequestForm.css similarity index 100% rename from src/wallet-user/trust-protection/CreateProtectionRequestForm.css rename to src/wallet-user/protection/CreateProtectionRequestForm.css diff --git a/src/wallet-user/trust-protection/CreateProtectionRequestForm.test.tsx b/src/wallet-user/protection/CreateProtectionRequestForm.test.tsx similarity index 100% rename from src/wallet-user/trust-protection/CreateProtectionRequestForm.test.tsx rename to src/wallet-user/protection/CreateProtectionRequestForm.test.tsx diff --git a/src/wallet-user/trust-protection/CreateProtectionRequestForm.tsx b/src/wallet-user/protection/CreateProtectionRequestForm.tsx similarity index 99% rename from src/wallet-user/trust-protection/CreateProtectionRequestForm.tsx rename to src/wallet-user/protection/CreateProtectionRequestForm.tsx index 391b584c..365cf118 100644 --- a/src/wallet-user/trust-protection/CreateProtectionRequestForm.tsx +++ b/src/wallet-user/protection/CreateProtectionRequestForm.tsx @@ -13,7 +13,7 @@ import { useCommonContext } from "../../common/CommonContext"; import { useUserContext } from "../UserContext"; import { CallCallback, useLogionChain } from '../../logion-chain'; -import { SETTINGS_PATH } from '../UserRouter'; +import { SETTINGS_PATH } from '../UserPaths'; import LegalOfficers from './LegalOfficers'; diff --git a/src/wallet-user/trust-protection/GoToRecovery.tsx b/src/wallet-user/protection/GoToRecovery.tsx similarity index 95% rename from src/wallet-user/trust-protection/GoToRecovery.tsx rename to src/wallet-user/protection/GoToRecovery.tsx index 2ebd5383..7923319f 100644 --- a/src/wallet-user/trust-protection/GoToRecovery.tsx +++ b/src/wallet-user/protection/GoToRecovery.tsx @@ -4,7 +4,7 @@ import { FullWidthPane } from '../../common/Dashboard'; import Alert from '../../common/Alert'; import Button from '../../common/Button'; -import { RECOVERY_PATH } from '../UserRouter'; +import { RECOVERY_PATH } from '../UserPaths'; export default function GoToRecovery() { const navigate = useNavigate(); diff --git a/src/wallet-user/trust-protection/LegalOfficers.css b/src/wallet-user/protection/LegalOfficers.css similarity index 100% rename from src/wallet-user/trust-protection/LegalOfficers.css rename to src/wallet-user/protection/LegalOfficers.css diff --git a/src/wallet-user/trust-protection/LegalOfficers.tsx b/src/wallet-user/protection/LegalOfficers.tsx similarity index 100% rename from src/wallet-user/trust-protection/LegalOfficers.tsx rename to src/wallet-user/protection/LegalOfficers.tsx diff --git a/src/wallet-user/trust-protection/Officer.css b/src/wallet-user/protection/Officer.css similarity index 100% rename from src/wallet-user/trust-protection/Officer.css rename to src/wallet-user/protection/Officer.css diff --git a/src/wallet-user/trust-protection/Officer.tsx b/src/wallet-user/protection/Officer.tsx similarity index 100% rename from src/wallet-user/trust-protection/Officer.tsx rename to src/wallet-user/protection/Officer.tsx diff --git a/src/wallet-user/trust-protection/ProtectionRecoveryRequest.css b/src/wallet-user/protection/ProtectionRecoveryRequest.css similarity index 100% rename from src/wallet-user/trust-protection/ProtectionRecoveryRequest.css rename to src/wallet-user/protection/ProtectionRecoveryRequest.css diff --git a/src/wallet-user/trust-protection/ProtectionRecoveryRequest.test.tsx b/src/wallet-user/protection/ProtectionRecoveryRequest.test.tsx similarity index 100% rename from src/wallet-user/trust-protection/ProtectionRecoveryRequest.test.tsx rename to src/wallet-user/protection/ProtectionRecoveryRequest.test.tsx diff --git a/src/wallet-user/trust-protection/ProtectionRecoveryRequest.tsx b/src/wallet-user/protection/ProtectionRecoveryRequest.tsx similarity index 99% rename from src/wallet-user/trust-protection/ProtectionRecoveryRequest.tsx rename to src/wallet-user/protection/ProtectionRecoveryRequest.tsx index 32c1d573..50172ce7 100644 --- a/src/wallet-user/trust-protection/ProtectionRecoveryRequest.tsx +++ b/src/wallet-user/protection/ProtectionRecoveryRequest.tsx @@ -17,7 +17,7 @@ import { useCommonContext } from '../../common/CommonContext'; import NetworkWarning from '../../common/NetworkWarning'; import { useUserContext } from '../UserContext'; -import { SETTINGS_PATH } from '../UserRouter'; +import { SETTINGS_PATH } from '../UserPaths'; import SelectLegalOfficer from './SelectLegalOfficer'; diff --git a/src/wallet-user/trust-protection/RecoveryRefusal.css b/src/wallet-user/protection/RecoveryRefusal.css similarity index 100% rename from src/wallet-user/trust-protection/RecoveryRefusal.css rename to src/wallet-user/protection/RecoveryRefusal.css diff --git a/src/wallet-user/trust-protection/RecoveryRefusal.tsx b/src/wallet-user/protection/RecoveryRefusal.tsx similarity index 100% rename from src/wallet-user/trust-protection/RecoveryRefusal.tsx rename to src/wallet-user/protection/RecoveryRefusal.tsx diff --git a/src/wallet-user/trust-protection/SelectLegalOfficer.css b/src/wallet-user/protection/SelectLegalOfficer.css similarity index 100% rename from src/wallet-user/trust-protection/SelectLegalOfficer.css rename to src/wallet-user/protection/SelectLegalOfficer.css diff --git a/src/wallet-user/trust-protection/SelectLegalOfficer.tsx b/src/wallet-user/protection/SelectLegalOfficer.tsx similarity index 100% rename from src/wallet-user/trust-protection/SelectLegalOfficer.tsx rename to src/wallet-user/protection/SelectLegalOfficer.tsx diff --git a/src/wallet-user/trust-protection/SelectLegalOfficerAndLoc.css b/src/wallet-user/protection/SelectLegalOfficerAndLoc.css similarity index 100% rename from src/wallet-user/trust-protection/SelectLegalOfficerAndLoc.css rename to src/wallet-user/protection/SelectLegalOfficerAndLoc.css diff --git a/src/wallet-user/trust-protection/SelectLegalOfficerAndLoc.tsx b/src/wallet-user/protection/SelectLegalOfficerAndLoc.tsx similarity index 100% rename from src/wallet-user/trust-protection/SelectLegalOfficerAndLoc.tsx rename to src/wallet-user/protection/SelectLegalOfficerAndLoc.tsx diff --git a/src/wallet-user/trust-protection/TestData.ts b/src/wallet-user/protection/TestData.ts similarity index 100% rename from src/wallet-user/trust-protection/TestData.ts rename to src/wallet-user/protection/TestData.ts diff --git a/src/wallet-user/trust-protection/TrustProtection.css b/src/wallet-user/protection/TrustProtection.css similarity index 100% rename from src/wallet-user/trust-protection/TrustProtection.css rename to src/wallet-user/protection/TrustProtection.css diff --git a/src/wallet-user/trust-protection/TrustProtection.test.tsx b/src/wallet-user/protection/TrustProtection.test.tsx similarity index 100% rename from src/wallet-user/trust-protection/TrustProtection.test.tsx rename to src/wallet-user/protection/TrustProtection.test.tsx diff --git a/src/wallet-user/trust-protection/TrustProtection.tsx b/src/wallet-user/protection/TrustProtection.tsx similarity index 100% rename from src/wallet-user/trust-protection/TrustProtection.tsx rename to src/wallet-user/protection/TrustProtection.tsx diff --git a/src/wallet-user/trust-protection/__snapshots__/CreateProtectionRequestForm.test.tsx.snap b/src/wallet-user/protection/__snapshots__/CreateProtectionRequestForm.test.tsx.snap similarity index 100% rename from src/wallet-user/trust-protection/__snapshots__/CreateProtectionRequestForm.test.tsx.snap rename to src/wallet-user/protection/__snapshots__/CreateProtectionRequestForm.test.tsx.snap diff --git a/src/wallet-user/trust-protection/__snapshots__/ProtectionRecoveryRequest.test.tsx.snap b/src/wallet-user/protection/__snapshots__/ProtectionRecoveryRequest.test.tsx.snap similarity index 100% rename from src/wallet-user/trust-protection/__snapshots__/ProtectionRecoveryRequest.test.tsx.snap rename to src/wallet-user/protection/__snapshots__/ProtectionRecoveryRequest.test.tsx.snap diff --git a/src/wallet-user/trust-protection/__snapshots__/TrustProtection.test.tsx.snap b/src/wallet-user/protection/__snapshots__/TrustProtection.test.tsx.snap similarity index 100% rename from src/wallet-user/trust-protection/__snapshots__/TrustProtection.test.tsx.snap rename to src/wallet-user/protection/__snapshots__/TrustProtection.test.tsx.snap diff --git a/src/wallet-user/trust-protection/GoToTrustProtection.css b/src/wallet-user/recovery/GoToTrustProtection.css similarity index 100% rename from src/wallet-user/trust-protection/GoToTrustProtection.css rename to src/wallet-user/recovery/GoToTrustProtection.css diff --git a/src/wallet-user/trust-protection/GoToTrustProtection.tsx b/src/wallet-user/recovery/GoToTrustProtection.tsx similarity index 97% rename from src/wallet-user/trust-protection/GoToTrustProtection.tsx rename to src/wallet-user/recovery/GoToTrustProtection.tsx index 914832bd..b59d504d 100644 --- a/src/wallet-user/trust-protection/GoToTrustProtection.tsx +++ b/src/wallet-user/recovery/GoToTrustProtection.tsx @@ -5,7 +5,7 @@ import Alert from '../../common/Alert'; import Button from '../../common/Button'; import { useCommonContext } from '../../common/CommonContext'; -import { TRUST_PROTECTION_PATH } from '../UserRouter'; +import { TRUST_PROTECTION_PATH } from '../UserPaths'; import './GoToTrustProtection.css'; import Frame from '../../common/Frame'; diff --git a/src/wallet-user/trust-protection/Recovery.test.tsx b/src/wallet-user/recovery/Recovery.test.tsx similarity index 95% rename from src/wallet-user/trust-protection/Recovery.test.tsx rename to src/wallet-user/recovery/Recovery.test.tsx index 9ad3c4a0..b0a6dbb9 100644 --- a/src/wallet-user/trust-protection/Recovery.test.tsx +++ b/src/wallet-user/recovery/Recovery.test.tsx @@ -4,10 +4,10 @@ jest.unmock("@logion/client"); import {shallowRender} from "../../tests"; import Recovery from "./Recovery"; import { setProtectionState } from '../__mocks__/UserContextMock'; -import { PENDING_RECOVERY_REQUESTS, ACCEPTED_RECOVERY_REQUESTS, ACTIVATED_RECOVERY_REQUESTS } from "./TestData"; +import { PENDING_RECOVERY_REQUESTS, ACCEPTED_RECOVERY_REQUESTS, ACTIVATED_RECOVERY_REQUESTS } from "../protection/TestData"; import { PendingProtection, AcceptedProtection, PendingRecovery, ClaimedRecovery } from "@logion/client"; import { RecoverySharedState } from "@logion/client/dist/Recovery.js"; -import { GUILLAUME, PATRICK } from "src/common/TestData"; +import { GUILLAUME, PATRICK } from "../../common/TestData"; test("renders", () => { setProtectionState(undefined); diff --git a/src/wallet-user/trust-protection/Recovery.tsx b/src/wallet-user/recovery/Recovery.tsx similarity index 91% rename from src/wallet-user/trust-protection/Recovery.tsx rename to src/wallet-user/recovery/Recovery.tsx index 65b63866..afa68e4c 100644 --- a/src/wallet-user/trust-protection/Recovery.tsx +++ b/src/wallet-user/recovery/Recovery.tsx @@ -1,8 +1,8 @@ import { useUserContext } from "../UserContext"; import GoToTrustProtection from './GoToTrustProtection'; -import CreateProtectionRequestForm from "./CreateProtectionRequestForm"; -import ProtectionRecoveryRequest from './ProtectionRecoveryRequest'; +import CreateProtectionRequestForm from "../protection/CreateProtectionRequestForm"; +import ProtectionRecoveryRequest from '../protection/ProtectionRecoveryRequest'; import RecoveryProcess from './RecoveryProcess'; import { AcceptedProtection, diff --git a/src/wallet-user/trust-protection/RecoveryProcess.css b/src/wallet-user/recovery/RecoveryProcess.css similarity index 100% rename from src/wallet-user/trust-protection/RecoveryProcess.css rename to src/wallet-user/recovery/RecoveryProcess.css diff --git a/src/wallet-user/trust-protection/RecoveryProcess.tsx b/src/wallet-user/recovery/RecoveryProcess.tsx similarity index 98% rename from src/wallet-user/trust-protection/RecoveryProcess.tsx rename to src/wallet-user/recovery/RecoveryProcess.tsx index e7f8da75..3778e2bd 100644 --- a/src/wallet-user/trust-protection/RecoveryProcess.tsx +++ b/src/wallet-user/recovery/RecoveryProcess.tsx @@ -6,7 +6,7 @@ import Tabs from '../../common/Tabs'; import Icon from '../../common/Icon'; import NetworkWarning from '../../common/NetworkWarning'; -import { SETTINGS_PATH } from '../UserRouter'; +import { SETTINGS_PATH } from '../UserPaths'; import { useUserContext } from '../UserContext'; import WalletRecoveryProcessTab from "./WalletRecoveryProcessTab"; diff --git a/src/wallet-user/trust-protection/VaultRecoveryProcessTab.css b/src/wallet-user/recovery/VaultRecoveryProcessTab.css similarity index 100% rename from src/wallet-user/trust-protection/VaultRecoveryProcessTab.css rename to src/wallet-user/recovery/VaultRecoveryProcessTab.css diff --git a/src/wallet-user/trust-protection/VaultRecoveryProcessTab.tsx b/src/wallet-user/recovery/VaultRecoveryProcessTab.tsx similarity index 97% rename from src/wallet-user/trust-protection/VaultRecoveryProcessTab.tsx rename to src/wallet-user/recovery/VaultRecoveryProcessTab.tsx index 0adad799..35fd2dd3 100644 --- a/src/wallet-user/trust-protection/VaultRecoveryProcessTab.tsx +++ b/src/wallet-user/recovery/VaultRecoveryProcessTab.tsx @@ -18,12 +18,12 @@ import ButtonGroup from "../../common/ButtonGroup"; import { useUserContext } from "../UserContext"; -import { buildOptions } from "./SelectLegalOfficer"; +import { buildOptions } from "../protection/SelectLegalOfficer"; import "./VaultRecoveryProcessTab.css" -import CoinIcon from "src/components/coin/CoinIcon"; -import ExtrinsicSubmissionStateView from "src/ExtrinsicSubmissionStateView"; -import AmountCell from "src/common/AmountCell"; -import AssetNameCell from "src/common/AssetNameCell"; +import CoinIcon from "../../components/coin/CoinIcon"; +import ExtrinsicSubmissionStateView from "../../ExtrinsicSubmissionStateView"; +import AmountCell from "../../common/AmountCell"; +import AssetNameCell from "../../common/AssetNameCell"; interface FormValues { legalOfficer: string | null; diff --git a/src/wallet-user/trust-protection/WalletRecoveryProcessTab.test.tsx b/src/wallet-user/recovery/WalletRecoveryProcessTab.test.tsx similarity index 100% rename from src/wallet-user/trust-protection/WalletRecoveryProcessTab.test.tsx rename to src/wallet-user/recovery/WalletRecoveryProcessTab.test.tsx diff --git a/src/wallet-user/trust-protection/WalletRecoveryProcessTab.tsx b/src/wallet-user/recovery/WalletRecoveryProcessTab.tsx similarity index 94% rename from src/wallet-user/trust-protection/WalletRecoveryProcessTab.tsx rename to src/wallet-user/recovery/WalletRecoveryProcessTab.tsx index 111f45de..ee77081a 100644 --- a/src/wallet-user/trust-protection/WalletRecoveryProcessTab.tsx +++ b/src/wallet-user/recovery/WalletRecoveryProcessTab.tsx @@ -12,11 +12,11 @@ import IconTextRow from "../../common/IconTextRow"; import { CallCallback, useLogionChain } from "../../logion-chain"; import { useUserContext } from "../UserContext"; -import CoinIcon from "src/components/coin/CoinIcon"; -import ExtrinsicSubmissionStateView from "src/ExtrinsicSubmissionStateView"; -import AmountCell from "src/common/AmountCell"; -import { ExpectNewTransactionStatus, useCommonContext } from "src/common/CommonContext"; -import AssetNameCell from "src/common/AssetNameCell"; +import CoinIcon from "../../components/coin/CoinIcon"; +import ExtrinsicSubmissionStateView from "../../ExtrinsicSubmissionStateView"; +import AmountCell from "../../common/AmountCell"; +import { ExpectNewTransactionStatus, useCommonContext } from "../../common/CommonContext"; +import AssetNameCell from "../../common/AssetNameCell"; interface Props { vaultFirst: boolean @@ -164,7 +164,7 @@ export default function WalletRecoveryProcessTab(props: Props) {

Transfer successful, waiting for the transaction to be finalized.

Note that this may take up to 30 seconds. If you want to proceed, you can safely - click on cancel but your transaction may not show up yet.

+ click on close but your transaction may not show up yet.

} diff --git a/src/wallet-user/trust-protection/__snapshots__/Recovery.test.tsx.snap b/src/wallet-user/recovery/__snapshots__/Recovery.test.tsx.snap similarity index 100% rename from src/wallet-user/trust-protection/__snapshots__/Recovery.test.tsx.snap rename to src/wallet-user/recovery/__snapshots__/Recovery.test.tsx.snap diff --git a/src/wallet-user/trust-protection/__mocks__/Model.tsx b/src/wallet-user/trust-protection/__mocks__/Model.tsx deleted file mode 100644 index 1da181db..00000000 --- a/src/wallet-user/trust-protection/__mocks__/Model.tsx +++ /dev/null @@ -1,3 +0,0 @@ -export function checkActivation() { - return Promise.resolve(); -}