Compare commits
No commits in common. "9dc160e89c1046610f3d4b1541334496a4decf89" and "722aecda39925cb9fd34dd65aa3ac877aa435600" have entirely different histories.
9dc160e89c
...
722aecda39
@ -23,7 +23,7 @@ interface PdfMarkingProps {
|
|||||||
meta: Meta | null
|
meta: Meta | null
|
||||||
otherUserMarks: Mark[]
|
otherUserMarks: Mark[]
|
||||||
setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void
|
setCurrentUserMarks: (currentUserMarks: CurrentUserMark[]) => void
|
||||||
setIsMarksCompleted: (isMarksCompleted: boolean) => void
|
setIsReadyToSign: (isReadyToSign: boolean) => void
|
||||||
setUpdatedMarks: (markToUpdate: Mark) => void
|
setUpdatedMarks: (markToUpdate: Mark) => void
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +37,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
|||||||
const {
|
const {
|
||||||
files,
|
files,
|
||||||
currentUserMarks,
|
currentUserMarks,
|
||||||
setIsMarksCompleted,
|
setIsReadyToSign,
|
||||||
setCurrentUserMarks,
|
setCurrentUserMarks,
|
||||||
setUpdatedMarks,
|
setUpdatedMarks,
|
||||||
handleDownload,
|
handleDownload,
|
||||||
@ -101,7 +101,7 @@ const PdfMarking = (props: PdfMarkingProps) => {
|
|||||||
)
|
)
|
||||||
setCurrentUserMarks(updatedCurrentUserMarks)
|
setCurrentUserMarks(updatedCurrentUserMarks)
|
||||||
setSelectedMark(null)
|
setSelectedMark(null)
|
||||||
setIsMarksCompleted(true)
|
setIsReadyToSign(true)
|
||||||
setUpdatedMarks(updatedMark.mark)
|
setUpdatedMarks(updatedMark.mark)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,7 +39,7 @@ import { Container } from '../../components/Container'
|
|||||||
import { DisplayMeta } from './internal/displayMeta'
|
import { DisplayMeta } from './internal/displayMeta'
|
||||||
import styles from './style.module.scss'
|
import styles from './style.module.scss'
|
||||||
import { CurrentUserMark, Mark } from '../../types/mark.ts'
|
import { CurrentUserMark, Mark } from '../../types/mark.ts'
|
||||||
import { getLastSignersSig, isFullySigned } from '../../utils/sign.ts'
|
import { getLastSignersSig } from '../../utils/sign.ts'
|
||||||
import {
|
import {
|
||||||
filterMarksByPubkey,
|
filterMarksByPubkey,
|
||||||
getCurrentUserMarks,
|
getCurrentUserMarks,
|
||||||
@ -112,13 +112,13 @@ export const SignPage = () => {
|
|||||||
const [currentUserMarks, setCurrentUserMarks] = useState<CurrentUserMark[]>(
|
const [currentUserMarks, setCurrentUserMarks] = useState<CurrentUserMark[]>(
|
||||||
[]
|
[]
|
||||||
)
|
)
|
||||||
const [isMarksCompleted, setIsMarksCompleted] = useState(false)
|
const [isReadyToSign, setIsReadyToSign] = useState(false)
|
||||||
const [otherUserMarks, setOtherUserMarks] = useState<Mark[]>([])
|
const [otherUserMarks, setOtherUserMarks] = useState<Mark[]>([])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (signers.length > 0) {
|
if (signers.length > 0) {
|
||||||
// check if all signers have signed then its fully signed
|
// check if all signers have signed then its fully signed
|
||||||
if (isFullySigned(signers, signedBy)) {
|
if (signers.every((signer) => signedBy.includes(signer))) {
|
||||||
setSignedStatus(SignedStatus.Fully_Signed)
|
setSignedStatus(SignedStatus.Fully_Signed)
|
||||||
} else {
|
} else {
|
||||||
for (const signer of signers) {
|
for (const signer of signers) {
|
||||||
@ -216,7 +216,7 @@ export const SignPage = () => {
|
|||||||
const otherUserMarks = findOtherUserMarks(signedMarks, usersPubkey!)
|
const otherUserMarks = findOtherUserMarks(signedMarks, usersPubkey!)
|
||||||
setOtherUserMarks(otherUserMarks)
|
setOtherUserMarks(otherUserMarks)
|
||||||
setCurrentUserMarks(currentUserMarks)
|
setCurrentUserMarks(currentUserMarks)
|
||||||
setIsMarksCompleted(isCurrentUserMarksComplete(currentUserMarks))
|
setIsReadyToSign(isCurrentUserMarksComplete(currentUserMarks))
|
||||||
}
|
}
|
||||||
|
|
||||||
setSignedBy(Object.keys(meta.docSignatures) as `npub1${string}`[])
|
setSignedBy(Object.keys(meta.docSignatures) as `npub1${string}`[])
|
||||||
@ -883,90 +883,90 @@ export const SignPage = () => {
|
|||||||
return <LoadingSpinner desc={loadingSpinnerDesc} />
|
return <LoadingSpinner desc={loadingSpinnerDesc} />
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!isMarksCompleted && signedStatus === SignedStatus.User_Is_Next_Signer) {
|
if (isReadyToSign) {
|
||||||
return (
|
return (
|
||||||
<PdfMarking
|
<>
|
||||||
files={getCurrentUserFiles(files, currentFileHashes, creatorFileHashes)}
|
<Container className={styles.container}>
|
||||||
currentUserMarks={currentUserMarks}
|
{displayInput && (
|
||||||
setIsMarksCompleted={setIsMarksCompleted}
|
<>
|
||||||
setCurrentUserMarks={setCurrentUserMarks}
|
<Typography component="label" variant="h6">
|
||||||
setUpdatedMarks={setUpdatedMarks}
|
Select sigit file
|
||||||
handleDownload={handleDownload}
|
</Typography>
|
||||||
otherUserMarks={otherUserMarks}
|
|
||||||
meta={meta}
|
<Box className={styles.inputBlock}>
|
||||||
/>
|
<MuiFileInput
|
||||||
|
placeholder="Select file"
|
||||||
|
inputProps={{ accept: '.sigit.zip' }}
|
||||||
|
value={selectedFile}
|
||||||
|
onChange={(value) => setSelectedFile(value)}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
{selectedFile && (
|
||||||
|
<Box sx={{ mt: 2, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<Button onClick={handleDecrypt} variant="contained">
|
||||||
|
Decrypt
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{submittedBy && Object.entries(files).length > 0 && meta && (
|
||||||
|
<>
|
||||||
|
<DisplayMeta
|
||||||
|
meta={meta}
|
||||||
|
files={files}
|
||||||
|
submittedBy={submittedBy}
|
||||||
|
signers={signers}
|
||||||
|
viewers={viewers}
|
||||||
|
creatorFileHashes={creatorFileHashes}
|
||||||
|
currentFileHashes={currentFileHashes}
|
||||||
|
signedBy={signedBy}
|
||||||
|
nextSigner={nextSinger}
|
||||||
|
getPrevSignersSig={getPrevSignersSig}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{signedStatus === SignedStatus.Fully_Signed && (
|
||||||
|
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<Button onClick={handleExport} variant="contained">
|
||||||
|
Export
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{signedStatus === SignedStatus.User_Is_Next_Signer && (
|
||||||
|
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<Button onClick={handleSign} variant="contained">
|
||||||
|
Sign
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
|
||||||
|
{isSignerOrCreator && (
|
||||||
|
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
||||||
|
<Button onClick={handleExportSigit} variant="contained">
|
||||||
|
Export Sigit
|
||||||
|
</Button>
|
||||||
|
</Box>
|
||||||
|
)}
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
</Container>
|
||||||
|
</>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<PdfMarking
|
||||||
<Container className={styles.container}>
|
files={getCurrentUserFiles(files, currentFileHashes, creatorFileHashes)}
|
||||||
{displayInput && (
|
currentUserMarks={currentUserMarks}
|
||||||
<>
|
setIsReadyToSign={setIsReadyToSign}
|
||||||
<Typography component="label" variant="h6">
|
setCurrentUserMarks={setCurrentUserMarks}
|
||||||
Select sigit file
|
setUpdatedMarks={setUpdatedMarks}
|
||||||
</Typography>
|
handleDownload={handleDownload}
|
||||||
|
otherUserMarks={otherUserMarks}
|
||||||
<Box className={styles.inputBlock}>
|
meta={meta}
|
||||||
<MuiFileInput
|
/>
|
||||||
placeholder="Select file"
|
|
||||||
inputProps={{ accept: '.sigit.zip' }}
|
|
||||||
value={selectedFile}
|
|
||||||
onChange={(value) => setSelectedFile(value)}
|
|
||||||
/>
|
|
||||||
</Box>
|
|
||||||
|
|
||||||
{selectedFile && (
|
|
||||||
<Box sx={{ mt: 2, display: 'flex', justifyContent: 'center' }}>
|
|
||||||
<Button onClick={handleDecrypt} variant="contained">
|
|
||||||
Decrypt
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{submittedBy && Object.entries(files).length > 0 && meta && (
|
|
||||||
<>
|
|
||||||
<DisplayMeta
|
|
||||||
meta={meta}
|
|
||||||
files={files}
|
|
||||||
submittedBy={submittedBy}
|
|
||||||
signers={signers}
|
|
||||||
viewers={viewers}
|
|
||||||
creatorFileHashes={creatorFileHashes}
|
|
||||||
currentFileHashes={currentFileHashes}
|
|
||||||
signedBy={signedBy}
|
|
||||||
nextSigner={nextSinger}
|
|
||||||
getPrevSignersSig={getPrevSignersSig}
|
|
||||||
/>
|
|
||||||
|
|
||||||
{signedStatus === SignedStatus.Fully_Signed && (
|
|
||||||
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
|
||||||
<Button onClick={handleExport} variant="contained">
|
|
||||||
Export
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{signedStatus === SignedStatus.User_Is_Next_Signer && (
|
|
||||||
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
|
||||||
<Button onClick={handleSign} variant="contained">
|
|
||||||
Sign
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
|
|
||||||
{isSignerOrCreator && (
|
|
||||||
<Box sx={{ mt: 1, display: 'flex', justifyContent: 'center' }}>
|
|
||||||
<Button onClick={handleExportSigit} variant="contained">
|
|
||||||
Export Sigit
|
|
||||||
</Button>
|
|
||||||
</Box>
|
|
||||||
)}
|
|
||||||
</>
|
|
||||||
)}
|
|
||||||
</Container>
|
|
||||||
</>
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -31,16 +31,4 @@ const getLastSignersSig = (
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
export { getLastSignersSig }
|
||||||
* Checks if all signers have signed the sigit
|
|
||||||
* @param signers - an array of npubs of all signers from the Sigit
|
|
||||||
* @param signedBy - an array of npubs that have signed it already
|
|
||||||
*/
|
|
||||||
const isFullySigned = (
|
|
||||||
signers: `npub1${string}`[],
|
|
||||||
signedBy: `npub1${string}`[]
|
|
||||||
): boolean => {
|
|
||||||
return signers.every((signer) => signedBy.includes(signer))
|
|
||||||
}
|
|
||||||
|
|
||||||
export { getLastSignersSig, isFullySigned }
|
|
||||||
|
Loading…
Reference in New Issue
Block a user