import React, { useRef, useState } from 'react'; import { CurrentView, Post } from '../types'; import { SECTION_IDS, BLOG_POST_DETAIL_CONTENT, UI_TEXTS } from '../constants'; // Removed mockPosts import Button from './Button'; import { ArrowUturnLeftIcon, PlayIcon, PauseIcon, ChevronRightIcon } from './icons'; import ItemDetailNavigation from './ItemDetailNavigation'; import PostCard from './PostCard'; import GalleryComponent from './GalleryComponent'; // Import GalleryComponent interface BlogPostDetailProps { itemId: string; allPosts: Post[]; setCurrentView: (view: CurrentView) => void; setSelectedItemId: (id: string | null) => void; } const BlogPostDetail: React.FC = ({ itemId, allPosts, setCurrentView, setSelectedItemId }) => { const post = allPosts.find(p => p.id === itemId); const videoRef = useRef(null); const [isVideoPlaying, setIsVideoPlaying] = useState(false); const handleBackClick = () => { setCurrentView('storiesAll'); setSelectedItemId(null); }; const handleNavigateItem = (newItemId: string) => { setSelectedItemId(newItemId); }; const handleShowAllKeepReading = (e: React.MouseEvent) => { e.preventDefault(); setCurrentView('storiesAll'); setSelectedItemId(null); }; if (!post) { return (

{BLOG_POST_DETAIL_CONTENT.notFoundTitle}

); } const currentIndex = allPosts.findIndex(p => p.id === itemId); const previousPost = currentIndex > 0 ? allPosts[currentIndex - 1] : undefined; const nextPost = currentIndex < allPosts.length - 1 ? allPosts[currentIndex + 1] : undefined; const relatedPosts = allPosts .filter(p => p.id !== itemId) .slice(0, 3); const toggleVideoPlay = (e: React.MouseEvent) => { e.stopPropagation(); if (videoRef.current) { if (videoRef.current.paused) { videoRef.current.play(); setIsVideoPlaying(true); } else { videoRef.current.pause(); setIsVideoPlaying(false); } } }; return (
{post.videoUrl ? (
) : post.imageUrl && (
{post.title}
)}

{post.title}

{post.category} {(post.date || post.readTime) && } {post.date && {post.date}} {post.date && post.readTime && } {post.readTime && {post.readTime}}
{typeof post.fullContent === 'string' ? (
) : ( post.fullContent )}
{post.gallery && post.gallery.length > 0 && ( )}
{relatedPosts.length > 0 && (

{BLOG_POST_DETAIL_CONTENT.keepReadingTitle || "Читайте также"}

{BLOG_POST_DETAIL_CONTENT.viewAllButtonText || `Все ${BLOG_POST_DETAIL_CONTENT.itemTypePlural}`}
{relatedPosts.map(relatedPost => ( ))}
)}
); }; export default BlogPostDetail;