sigit.io/src/components/PDFView/index.tsx

37 lines
1.1 KiB
TypeScript

import { PdfFile } from '../../types/drawing.ts'
import { Box } from '@mui/material'
import PdfItem from './PdfItem.tsx'
import { CurrentUserMark, Mark, MarkConfigDetails } from '../../types/mark.ts'
interface PdfViewProps {
files: { [filename: string]: PdfFile },
fileHashes: { [key: string]: string | null },
marks: Mark[],
handleMarkClick: (id: number) => void
currentMarkValue: string
currentUserMark: CurrentUserMark | null
}
const PdfView = ({ files, fileHashes, marks, handleMarkClick, currentMarkValue, currentUserMark }: PdfViewProps) => {
const filterByFile = (marks: Mark[], fileHash: string): Mark[] => {
return marks.filter((mark) => mark.pdfFileHash === fileHash);
}
return (
<Box sx={{ width: '100%' }}>
{Object.entries(files)
.map(([name, file], i) => (
<PdfItem
pdfFile={file}
key={i}
marks={filterByFile(marks, fileHashes[name] ?? "")}
handleMarkClick={handleMarkClick}
currentMarkValue={currentMarkValue}
currentUserMark={currentUserMark}
/>
))}
</Box>
)
}
export default PdfView;