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