import { useRoute, useLocation } from "wouter"; import { FileText, Presentation, Info, Search, Settings, User, LogOut, IdCard } from "lucide-react"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Card, CardContent } from "@/components/ui/card"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from "@/components/ui/tooltip"; import { Slider } from "@/components/ui/slider"; import { useQuery } from "@tanstack/react-query"; import { useAuth } from "@/hooks/useAuth"; import { useState, useEffect, useRef, useMemo } from "react"; import type { MediaOutlet } from "@shared/schema"; import Footer from "@/components/Footer"; import SearchModal from "@/components/SearchModal"; import { Document, Page, pdfjs } from 'react-pdf'; pdfjs.GlobalWorkerOptions.workerSrc = '/pdf.worker.min.mjs'; const reportContent: Record = { 'chayan-asli': { htmlPath: '/attached_assets/chayan asli report_1759208054055.html', pptPath: '/attached_assets/chayan asli slides_1759213492580.pptx' }, 'krysh-parker': { htmlPath: '/attached_assets/krysh parker report_1759209671294.html', pptPath: '/attached_assets/krysh parker slides_1759209102236.pptx' }, 'mohamed-salah': { htmlPath: '/attached_assets/Mohamed Salah_Report_en_1760420154846.html', pdfPath: '/attached_assets/mohamed_salah_pdf_en_1760419721874.pdf', customComponent: true } }; function MohamedSalahSlides() { const [currentSlide, setCurrentSlide] = useState(1); const [numPages, setNumPages] = useState(0); const [isLoading, setIsLoading] = useState(true); const [hoverSlide, setHoverSlide] = useState(null); const [hoverPosition, setHoverPosition] = useState({ x: 0, y: 0 }); const onDocumentLoadSuccess = ({ numPages }: { numPages: number }) => { setNumPages(numPages); setCurrentSlide(1); // Reset to first slide after load setIsLoading(false); }; const pdfOptions = useMemo(() => ({ cMapUrl: 'https://unpkg.com/pdfjs-dist@3.11.174/cmaps/', cMapPacked: true, }), []); const handleSliderChange = (value: number[]) => { if (numPages > 0) { setCurrentSlide(value[0]); } }; const handleSliderCommit = (value: number[]) => { if (numPages > 0) { setCurrentSlide(value[0]); } }; const handleSliderClick = (e: React.MouseEvent) => { if (numPages === 0) return; const rect = e.currentTarget.getBoundingClientRect(); const x = e.clientX - rect.left; const percentage = x / rect.width; const slideNumber = Math.max(1, Math.min(numPages, Math.round(percentage * numPages))); setCurrentSlide(slideNumber); }; const handleSliderHover = (e: React.MouseEvent) => { if (numPages === 0) return; const rect = e.currentTarget.getBoundingClientRect(); const x = e.clientX - rect.left; const percentage = x / rect.width; const slideNumber = Math.max(1, Math.min(numPages, Math.round(percentage * numPages))); setHoverSlide(slideNumber); setHoverPosition({ x: e.clientX, y: rect.top - 60 }); }; const handleSliderLeave = () => { setHoverSlide(null); }; return (
{isLoading && (

Loading slides...

)}
{/* Progress Bar */}
{/* Slide markers */}
{numPages > 0 && Array.from({ length: numPages }).map((_, i) => (
))}
{/* Hover tooltip */} {hoverSlide !== null && (
Slide {hoverSlide}
)}
{/* Control buttons */}
Slide {currentSlide} of {numPages}
); } export default function Report() { const [, params] = useRoute("/media/:slug/report"); const [, setLocation] = useLocation(); const [enlargedImage, setEnlargedImage] = useState(null); const [isSearchModalOpen, setIsSearchModalOpen] = useState(false); const { user, isAuthenticated } = useAuth(); const slug = params?.slug || ''; const content = reportContent[slug] || reportContent['chayan-asli']; const { data: outlet, isLoading: outletLoading } = useQuery({ queryKey: ["/api/media-outlets", slug], enabled: !!slug }); const handleLogout = async () => { try { const response = await fetch("/api/logout", { method: "POST", credentials: "include", }); if (response.ok) { window.location.href = "/"; } } catch (error) { console.error("Logout failed:", error); } }; const handleAdminPage = () => { if (user?.role === "admin" || user?.role === "superadmin") { setLocation("/admin"); } }; // Get full URL for PPT file const getFullPptUrl = () => { const baseUrl = window.location.origin; return `${baseUrl}${content.pptPath}`; }; // Enhance report styling const handleReportLoad = (e: React.SyntheticEvent) => { try { const iframe = e.currentTarget; const iframeDoc = iframe.contentDocument || iframe.contentWindow?.document; if (iframeDoc && iframeDoc.body) { // Wrap all body content in a container if not already wrapped if (!iframeDoc.querySelector('.sapiens-report-wrapper')) { const wrapper = iframeDoc.createElement('div'); wrapper.className = 'sapiens-report-wrapper'; while (iframeDoc.body.firstChild) { wrapper.appendChild(iframeDoc.body.firstChild); } iframeDoc.body.appendChild(wrapper); } const style = iframeDoc.createElement('style'); style.textContent = ` html, body { margin: 0 !important; padding: 0 !important; background: linear-gradient(135deg, #f5f7fa 0%, #e8ecf1 100%) !important; max-width: none !important; width: 100% !important; } body { padding: 48px 32px !important; } .sapiens-report-wrapper { background: white !important; border-radius: 16px !important; box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1) !important; padding: 56px !important; max-width: 1000px !important; margin: 0 auto !important; text-align: center !important; } .sapiens-report-wrapper p { text-align: justify !important; } h1 { font-size: 36px !important; font-weight: 700 !important; color: #1a202c !important; margin-bottom: 28px !important; margin-top: 0 !important; padding-bottom: 20px !important; border-bottom: 3px solid #3b82f6 !important; background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%) !important; -webkit-background-clip: text !important; -webkit-text-fill-color: transparent !important; background-clip: text !important; } h2 { font-size: 26px !important; font-weight: 600 !important; color: #2d3748 !important; margin-top: 44px !important; margin-bottom: 18px !important; padding-bottom: 10px !important; border-bottom: 2px solid #e2e8f0 !important; } h3 { font-size: 22px !important; font-weight: 600 !important; color: #374151 !important; margin-top: 32px !important; margin-bottom: 14px !important; } h4 { font-size: 19px !important; font-weight: 600 !important; color: #4b5563 !important; margin-top: 26px !important; margin-bottom: 12px !important; } p { font-size: 17px !important; line-height: 1.8 !important; color: #374151 !important; margin-bottom: 18px !important; text-align: justify !important; } p + img, img + p { margin-top: 24px !important; } .metadata { background: linear-gradient(135deg, #eff6ff 0%, #dbeafe 100%) !important; padding: 24px !important; border-radius: 12px !important; border-left: 4px solid #3b82f6 !important; margin-bottom: 36px !important; font-size: 15px !important; color: #1e40af !important; text-align: center !important; } .section { margin-bottom: 36px !important; } ul, ol { margin-bottom: 20px !important; padding-left: 32px !important; text-align: left !important; } li { font-size: 17px !important; line-height: 1.8 !important; color: #4b5563 !important; margin-bottom: 10px !important; text-align: left !important; } .highlight { background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%) !important; padding: 24px !important; border-left: 4px solid #f59e0b !important; border-radius: 10px !important; margin: 28px 0 !important; box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.08) !important; } .quote { background: linear-gradient(135deg, #f3f4f6 0%, #e5e7eb 100%) !important; padding: 24px 28px !important; border-left: 4px solid #6b7280 !important; border-radius: 10px !important; margin: 28px 0 !important; font-style: italic !important; color: #374151 !important; box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.08) !important; } strong { font-weight: 700 !important; color: #1f2937 !important; } img { max-width: 100% !important; height: auto !important; border-radius: 12px !important; box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.15) !important; margin: 32px auto !important; display: block !important; clear: both !important; float: none !important; } table { max-width: 100% !important; width: 100% !important; border-collapse: collapse !important; margin: 20px 0 !important; } table, iframe { max-width: 100% !important; } @page { margin: 0 !important; } @media (max-width: 768px) { .sapiens-report-wrapper { padding: 32px 24px !important; } h1 { font-size: 28px !important; } h2 { font-size: 22px !important; } h3 { font-size: 19px !important; } } `; iframeDoc.head.appendChild(style); } } catch (e) { console.error('Could not inject styles into iframe:', e); } }; return (
{/* Header */}
{outletLoading ? ( <>
) : outlet ? ( <> {outlet.imageUrl ? ( {outlet.name} setEnlargedImage(outlet.imageUrl!)} data-testid="image-outlet-header-profile" /> ) : (
{outlet.name.charAt(0)}
)}
setLocation("/")}> SAPIENS
{outlet.name}
) : ( SAPIENS setLocation("/")} data-testid="logo-sapiens" /> )}
setIsSearchModalOpen(true)} data-testid="search-container" >
{isAuthenticated && user ? ( <>
{user.firstName} {user.lastName}
) : ( )}
{/* Main Content */}
Report Slides