import styles from '../DrawPDFFields/style.module.scss'
import { PdfPage } from '../../types/drawing.ts'
import { CurrentUserMark } from '../../types/mark.ts'
import PdfMarkItem from './PdfMarkItem.tsx'
interface PdfPageProps {
  page: PdfPage
  currentUserMarks: CurrentUserMark[]
  handleMarkClick: (id: number) => void
  selectedMarkValue: string
  selectedMark: CurrentUserMark | null
}

/**
 * Responsible for rendering a single Pdf Page and its Marks
 */
const PdfPageItem = ({ page, currentUserMarks, handleMarkClick, selectedMarkValue, selectedMark }: PdfPageProps) => {
  return (
    <div
      className={styles.pdfImageWrapper}
      style={{
        border: '1px solid #c4c4c4',
        marginBottom: '10px',
        marginTop: '10px'
      }}
    >
      <img
        draggable="false"
        src={page.image}
        style={{ width: '100%'}}

      />
      {
        currentUserMarks.map((m, i) => (
          <PdfMarkItem
            key={i}
            handleMarkClick={handleMarkClick}
            selectedMarkValue={selectedMarkValue}
            userMark={m}
            selectedMark={selectedMark}
        />
      ))}
    </div>
  )
}

export default PdfPageItem