"use client";
import React, { useState } from "react";
import {
ChevronRight,
Calendar,
User,
Clock,
Tag,
Share2,
MessageSquare,
Sparkles,
ShoppingBag,
ArrowLeft,
Send,
Eye,
} from "lucide-react";
import Link from 'next/link';
import SafeImage from "./SafeImage";
interface BlogPostClientProps {
blog: any;
publishedDate: string;
authorName: string;
}
export default function BlogPostClient({ blog, publishedDate, authorName }: BlogPostClientProps) {
const [copied, setCopied] = useState(false);
const [commentName, setCommentName] = useState("");
const [commentEmail, setCommentEmail] = useState("");
const [commentText, setCommentText] = useState("");
const [commentSent, setCommentSent] = useState(false);
const relatedProducts = Array.isArray(blog.relatedProducts) ? blog.relatedProducts : [];
const relatedBlogs = Array.isArray(blog.relatedBlogs) ? blog.relatedBlogs : [];
const comments = Array.isArray(blog.comments) ? blog.comments : [];
const handleShare = () => {
if (typeof window !== 'undefined') {
if (navigator.share) {
navigator.share({ title: blog.title, url: window.location.href }).catch(() => null);
} else {
navigator.clipboard.writeText(window.location.href);
setCopied(true);
setTimeout(() => setCopied(false), 3000);
}
}
};
const handleCommentSubmit = (e: React.FormEvent) => {
e.preventDefault();
setCommentSent(true);
setCommentName("");
setCommentEmail("");
setCommentText("");
};
return (
{/* Breadcrumbs */}
خانه
مجله سلامت
{blog.category && (
<>
{blog.category.name}
>
)}
{blog.title}
{/* Main Article Content Column */}
{/* Featured Image */}
{blog.imageUrl && (
{blog.imageCaption && (
{blog.imageCaption}
)}
)}
{/* Meta details bar */}
{blog.category && (
{blog.category.name}
)}
{publishedDate && (
{publishedDate}
)}
{blog.readingTime || 4} دقیقه مطالعه
{blog.viewCount || 0} بازدید
{/* Title */}
{blog.title}
{/* Excerpt / Summary Callout */}
{blog.excerpt && (
{blog.excerpt}
)}
{/* Main Rich Content HTML Renderer */}
{/* Tags Chip Footer */}
{Array.isArray(blog.tags) && blog.tags.length > 0 && (
برچسبهای مرتبط:
{blog.tags.map((tag: any, idx: number) => {
const tagName = typeof tag === 'string' ? tag : tag?.name || '';
const tagId = tag?.id || idx;
if (!tagName) return null;
return (
#{tagName}
);
})}
)}
{/* Author Box */}
{authorName}
تیم تحقیق و توسعه علمی کنینا آلمان (Canina Pharma)
{/* Comments Section */}
{blog.allowComments !== false && (
دیدگاهها و پرسشهای کاربران ({comments.length})
{commentSent ? (
دیدگاه شما با موفقیت ثبت شد و پس از بررسی و تایید تیم علمی، در سایت نمایش داده میشود.
) : (
)}
{/* Comments List */}
{comments.length > 0 ? (
{comments.map((c: any) => (
{c.authorName}
{c.createdAt ? new Date(c.createdAt).toLocaleDateString('fa-IR') : ''}
{c.content}
))}
) : (
هنوز دیدگاهی برای این مقاله ثبت نشده است. اولین نظر را شما بنویسید!
)}
)}
{/* Sidebar Column */}
);
}