import React, { useState } from "react"; import { Document, Page } from "react-pdf"; import "react-pdf/dist/Page/TextLayer.css"; import "react-pdf/dist/Page/AnnotationLayer.css"; import "./DocumentModal.scss"; import Button from "@/components/generics/button/Button"; import Input from "@/components/generics/input/Input"; import { GoChevronLeft, GoChevronRight } from "react-icons/go"; const PdfViewer: React.FC<{ file: Blob | null }> = ({ file }) => { const [numPages, setNumPages] = useState(null); const [currentPage, setCurrentPage] = useState(1); const [inputValue, setInputValue] = useState(currentPage.toString()); const onLoadSuccess = ({ numPages }: { numPages: number }) => { setNumPages(numPages); setCurrentPage(1); setInputValue("1"); }; const goToPage = (page: number) => { if (numPages && page >= 1 && page <= numPages) { setCurrentPage(page); setInputValue(page.toString()); } }; const handleInputChange = (value: string) => { setInputValue(value); const newValue = Number(value); if (!isNaN(newValue) && newValue >= 1 && newValue <= (numPages ?? 1)) { goToPage(newValue); } }; const handleInputBlur = () => { const newValue = Number(inputValue); if (isNaN(newValue) || newValue < 1 || newValue > (numPages ?? 1)) { setInputValue(currentPage.toString()); } else { goToPage(newValue); } }; return (
Загрузка документа...

}>
); }; export default PdfViewer;