// app/admin/upload/_components/step-2-pdf-viewer.tsx "use client"; import { useRef } from "react"; import { usePdfViewer } from "../_hooks/use-pdf-viewer"; import { Button } from "@/shared/components/ui/button"; import { Checkbox } from "@/shared/components/ui/checkbox"; import { Loader2, CheckSquare, Square } from "lucide-react"; import { motion } from "framer-motion"; export default function StepPdfViewer() { const { pages, loading, localSelectedPages, toggleSelectPage, handleProcessPdf, // Fitur Baru dari Hook handleSelectAll, isAllSelected, MAX_SELECT } = usePdfViewer(); // 🔥 REF UNTUK SCROLLING const pageRefs = useRef<{ [key: number]: HTMLDivElement | null }>({}); // Fungsi Helper Scroll const scrollToPage = (pageNum: number) => { const element = pageRefs.current[pageNum]; if (element) { element.scrollIntoView({ behavior: "smooth", block: "start" }); } }; const handleSidebarClick = (pageNum: number) => { toggleSelectPage(pageNum); // Auto scroll hanya jika kita mencentang (opsional: bisa juga scroll saat uncheck jika mau) // Disini saya buat scroll terjadi setiap kali klik baris scrollToPage(pageNum); }; return (
Maksimal {MAX_SELECT} halaman.