diff --git a/src/components/DisplaySigit/index.tsx b/src/components/DisplaySigit/index.tsx index 62f397c..ab36851 100644 --- a/src/components/DisplaySigit/index.tsx +++ b/src/components/DisplaySigit/index.tsx @@ -22,11 +22,16 @@ import { useSigitMeta } from '../../hooks/useSigitMeta' import { extractFileExtensions } from '../../utils/file' type SigitProps = { + sigitCreateId: string meta: Meta parsedMeta: SigitCardDisplayInfo } -export const DisplaySigit = ({ meta, parsedMeta }: SigitProps) => { +export const DisplaySigit = ({ + meta, + parsedMeta, + sigitCreateId: sigitCreateId +}: SigitProps) => { const { title, createdAt, submittedBy, signers, signedStatus, isValid } = parsedMeta @@ -35,15 +40,19 @@ export const DisplaySigit = ({ meta, parsedMeta }: SigitProps) => { return (
- + {signedStatus === SigitStatus.Complete && ( + + )} + {signedStatus !== SigitStatus.Complete && ( + + )}

{title}

{submittedBy && ( diff --git a/src/pages/home/index.tsx b/src/pages/home/index.tsx index c93c9f8..1a29021 100644 --- a/src/pages/home/index.tsx +++ b/src/pages/home/index.tsx @@ -257,6 +257,7 @@ export const HomePage = () => { .map((key) => ( diff --git a/src/pages/sign/index.tsx b/src/pages/sign/index.tsx index 63e71dd..80b0c00 100644 --- a/src/pages/sign/index.tsx +++ b/src/pages/sign/index.tsx @@ -7,7 +7,7 @@ import { MuiFileInput } from 'mui-file-input' import { Event, verifyEvent } from 'nostr-tools' import { useCallback, useEffect, useState } from 'react' import { useSelector } from 'react-redux' -import { useLocation, useNavigate } from 'react-router-dom' +import { useLocation, useNavigate, useParams } from 'react-router-dom' import { toast } from 'react-toastify' import { LoadingSpinner } from '../../components/LoadingSpinner' import { NostrController } from '../../controllers' @@ -54,6 +54,7 @@ import { SigitFile } from '../../utils/file.ts' import { ARRAY_BUFFER, DEFLATE } from '../../utils/const.ts' +import { useAppSelector } from '../../hooks/store.ts' enum SignedStatus { Fully_Signed, User_Is_Next_Signer, @@ -63,17 +64,39 @@ enum SignedStatus { export const SignPage = () => { const navigate = useNavigate() const location = useLocation() + const params = useParams() + + const usersAppData = useAppSelector((state) => state.userAppData) /** + * Received from `location.state` + * * uploadedZip will be received from home page when a user uploads a sigit zip wrapper that contains keys.json - * arrayBuffer will be received in navigation from create page in offline mode - * meta will be received in navigation from create & home page in online mode + * arrayBuffer (decryptedArrayBuffer) will be received in navigation from create page in offline mode + * meta (metaInNavState) will be received in navigation from create & home page in online mode */ - const { - meta: metaInNavState, - arrayBuffer: decryptedArrayBuffer, - uploadedZip - } = location.state || {} + let metaInNavState = location?.state?.meta || undefined + const { arrayBuffer: decryptedArrayBuffer, uploadedZip } = location.state || { + decryptedArrayBuffer: undefined, + uploadedZip: undefined + } + + /** + * If userAppData (redux) is available, and we have the route param (sigit id) + * which is actually a `createEventId`, we will fetch a `sigit` + * based on the provided route ID and set fetched `sigit` to the `metaInNavState` + */ + if (usersAppData) { + const sigitCreateId = params.id + + if (sigitCreateId) { + const sigit = usersAppData.sigits[sigitCreateId] + + if (sigit) { + metaInNavState = sigit + } + } + } const [displayInput, setDisplayInput] = useState(false) diff --git a/src/routes/index.tsx b/src/routes/index.tsx index 2d36db1..3e42e78 100644 --- a/src/routes/index.tsx +++ b/src/routes/index.tsx @@ -129,7 +129,7 @@ export const privateRoutes = [ element: }, { - path: appPrivateRoutes.sign, + path: `${appPrivateRoutes.sign}/:id?`, element: }, {