refactor(sign): cleaner divider code in PDVview
This commit is contained in:
parent
d965e56f76
commit
b7eadf0081
@ -45,18 +45,17 @@ const PdfView = ({
|
|||||||
const filterMarksByFile = (marks: Mark[], hash: string): Mark[] => {
|
const filterMarksByFile = (marks: Mark[], hash: string): Mark[] => {
|
||||||
return marks.filter((mark) => mark.pdfFileHash === hash)
|
return marks.filter((mark) => mark.pdfFileHash === hash)
|
||||||
}
|
}
|
||||||
const isNotLastPdfFile = (index: number, files: CurrentUserFile[]): boolean =>
|
|
||||||
index !== files.length - 1
|
|
||||||
return (
|
return (
|
||||||
<div className="files-wrapper">
|
<div className="files-wrapper">
|
||||||
{files.length > 0 ? (
|
{files.length > 0 ? (
|
||||||
files.map((currentUserFile, index, arr) => {
|
files
|
||||||
|
.map<React.ReactNode>((currentUserFile) => {
|
||||||
const { hash, file, id } = currentUserFile
|
const { hash, file, id } = currentUserFile
|
||||||
|
|
||||||
if (!hash) return
|
if (!hash) return
|
||||||
return (
|
return (
|
||||||
<React.Fragment key={index}>
|
|
||||||
<div
|
<div
|
||||||
|
key={`file-${file.name}`}
|
||||||
id={file.name}
|
id={file.name}
|
||||||
className="file-wrapper"
|
className="file-wrapper"
|
||||||
ref={(el) => (pdfRefs.current[id] = el)}
|
ref={(el) => (pdfRefs.current[id] = el)}
|
||||||
@ -70,10 +69,13 @@ const PdfView = ({
|
|||||||
otherUserMarks={filterMarksByFile(otherUserMarks, hash)}
|
otherUserMarks={filterMarksByFile(otherUserMarks, hash)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
{isNotLastPdfFile(index, arr) && <FileDivider />}
|
|
||||||
</React.Fragment>
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
.reduce((prev, curr, i) => [
|
||||||
|
prev,
|
||||||
|
<FileDivider key={`separator-${i}`} />,
|
||||||
|
curr
|
||||||
|
])
|
||||||
) : (
|
) : (
|
||||||
<LoadingSpinner variant="small" />
|
<LoadingSpinner variant="small" />
|
||||||
)}
|
)}
|
||||||
|
Loading…
Reference in New Issue
Block a user