Compare commits
2 Commits
b6479db266
...
18637bbbc1
Author | SHA1 | Date | |
---|---|---|---|
18637bbbc1 | |||
eca31cea4f |
@ -1,6 +1,8 @@
|
||||
import { CurrentUserFile } from '../../types/file.ts'
|
||||
import styles from './style.module.scss'
|
||||
import { Button } from '@mui/material'
|
||||
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
||||
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
||||
|
||||
interface FileListProps {
|
||||
files: CurrentUserFile[]
|
||||
@ -26,8 +28,14 @@ const FileList = ({
|
||||
className={`${styles.fileItem} ${isActive(file) && styles.active}`}
|
||||
onClick={() => setCurrentFile(file)}
|
||||
>
|
||||
<span className={styles.fileNumber}>{file.id}</span>
|
||||
<span className={styles.fileName}>{file.filename}</span>
|
||||
<div className={styles.fileNumber}>{file.id}</div>
|
||||
<div className={styles.fileInfo}>
|
||||
<div className={styles.fileName}>{file.filename}</div>
|
||||
</div>
|
||||
|
||||
<div className={styles.fileVisual}>
|
||||
{file.isHashValid && <FontAwesomeIcon icon={faCheck} />}
|
||||
</div>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
@ -21,6 +21,12 @@ ul {
|
||||
padding: 0; /* Removes default padding */
|
||||
}
|
||||
|
||||
li {
|
||||
list-style-type: none; /* Removes the bullets */
|
||||
margin: 0; /* Removes any default margin */
|
||||
padding: 0; /* Removes any default padding */
|
||||
}
|
||||
|
||||
|
||||
.wrap {
|
||||
display: flex;
|
||||
@ -83,6 +89,12 @@ ul {
|
||||
color: white;
|
||||
}
|
||||
|
||||
.fileInfo {
|
||||
flex-grow: 1;
|
||||
font-size: 16px;
|
||||
font-weight: 500;
|
||||
}
|
||||
|
||||
.fileName {
|
||||
display: -webkit-box;
|
||||
-webkit-box-orient: vertical;
|
||||
@ -97,4 +109,15 @@ ul {
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
width: 10px;
|
||||
}
|
||||
|
||||
.fileVisual {
|
||||
display: flex;
|
||||
flex-shrink: 0;
|
||||
flex-direction: column;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
height: 25px;
|
||||
width: 25px;
|
||||
}
|
@ -952,7 +952,7 @@ export const SignPage = () => {
|
||||
|
||||
return (
|
||||
<PdfMarking
|
||||
files={getCurrentUserFiles(files, currentFileHashes)}
|
||||
files={getCurrentUserFiles(files, currentFileHashes, creatorFileHashes)}
|
||||
currentUserMarks={currentUserMarks}
|
||||
setIsReadyToSign={setIsReadyToSign}
|
||||
setCurrentUserMarks={setCurrentUserMarks}
|
||||
|
@ -170,17 +170,23 @@ export const VerifyPage = () => {
|
||||
|
||||
const [currentFileHashes, setCurrentFileHashes] = useState<{
|
||||
[key: string]: string | null
|
||||
}>(fileHashes)
|
||||
}>({})
|
||||
const [files, setFiles] = useState<{ [filename: string]: PdfFile }>({})
|
||||
const [currentFile, setCurrentFile] = useState<CurrentUserFile | null>(null)
|
||||
const [signatureFileHashes, setSignatureFileHashes] = useState<{
|
||||
[key: string]: string
|
||||
}>(fileHashes)
|
||||
|
||||
useEffect(() => {
|
||||
setSignatureFileHashes(fileHashes)
|
||||
}, [fileHashes])
|
||||
|
||||
useEffect(() => {
|
||||
if (Object.entries(files).length > 0) {
|
||||
const tmp = getCurrentUserFiles(files, fileHashes)
|
||||
|
||||
const tmp = getCurrentUserFiles(files, fileHashes, signatureFileHashes)
|
||||
setCurrentFile(tmp[0])
|
||||
}
|
||||
}, [fileHashes, files])
|
||||
}, [signatureFileHashes, fileHashes, files])
|
||||
|
||||
const usersPubkey = useSelector((state: State) => state.auth.usersPubkey)
|
||||
const nostrController = NostrController.getInstance()
|
||||
@ -524,7 +530,11 @@ export const VerifyPage = () => {
|
||||
<>
|
||||
{currentFile !== null && (
|
||||
<FileList
|
||||
files={getCurrentUserFiles(files, currentFileHashes)}
|
||||
files={getCurrentUserFiles(
|
||||
files,
|
||||
currentFileHashes,
|
||||
signatureFileHashes
|
||||
)}
|
||||
currentFile={currentFile}
|
||||
setCurrentFile={setCurrentFile}
|
||||
handleDownload={handleExport}
|
||||
@ -537,7 +547,11 @@ export const VerifyPage = () => {
|
||||
>
|
||||
<SlimPdfView
|
||||
currentFile={currentFile}
|
||||
files={getCurrentUserFiles(files, currentFileHashes)}
|
||||
files={getCurrentUserFiles(
|
||||
files,
|
||||
currentFileHashes,
|
||||
signatureFileHashes
|
||||
)}
|
||||
parsedSignatureEvents={parsedSignatureEvents}
|
||||
/>
|
||||
</StickySideColumns>
|
||||
|
@ -5,4 +5,5 @@ export interface CurrentUserFile {
|
||||
pdfFile: PdfFile
|
||||
filename: string
|
||||
hash?: string
|
||||
isHashValid: boolean
|
||||
}
|
||||
|
@ -72,17 +72,20 @@ export const timeout = (ms: number = 60000) => {
|
||||
* including its name, hash, and content
|
||||
* @param files
|
||||
* @param fileHashes
|
||||
* @param creatorFileHashes
|
||||
*/
|
||||
export const getCurrentUserFiles = (
|
||||
files: { [filename: string]: PdfFile },
|
||||
fileHashes: { [key: string]: string | null }
|
||||
fileHashes: { [key: string]: string | null },
|
||||
creatorFileHashes: { [key: string]: string }
|
||||
): CurrentUserFile[] => {
|
||||
return Object.entries(files).map(([filename, pdfFile], index) => {
|
||||
return {
|
||||
pdfFile,
|
||||
filename,
|
||||
id: index + 1,
|
||||
...(!!fileHashes[filename] && { hash: fileHashes[filename]! })
|
||||
...(!!fileHashes[filename] && { hash: fileHashes[filename]! }),
|
||||
isHashValid: creatorFileHashes[filename] === fileHashes[filename]
|
||||
}
|
||||
})
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user