Deals Reviews

Smart Electronics. Smart Deals.

Latest gadgets • Best p import React, { useState } from 'react'; import { Blog, Author, Comment } from '../types'; import { Calendar, User, Clock, ArrowLeft, Send, CheckCircle, Sparkles } from 'lucide-react'; interface BlogLayoutProps { blogs: Blog[]; authors: Author[]; selectedBlogId: string | null; setSelectedBlogId: (id: string | null) => void; setCurrentTab: (tab: string) => void; onProductSelect: (id: string) => void; } export default function BlogLayout({ blogs, authors, selectedBlogId, setSelectedBlogId, setCurrentTab, onProductSelect }: BlogLayoutProps) { const [activeCategory, setActiveCategory] = useState('All'); const [commentName, setCommentName] = useState(''); const [commentText, setCommentText] = useState(''); const [commentsList, setCommentsList] = useState>({}); const [commentSuccess, setCommentSuccess] = useState(false); const blogCategories = ['All', ...Array.from(new Set(blogs.map(b => b.category)))]; // Get current active blog if chosen const activeBlog = blogs.find(b => b.id === selectedBlogId); const activeAuthor = activeBlog ? authors.find(a => a.id === activeBlog.authorId) : null; const handleCommentSubmit = (e: React.FormEvent, blogId: string) => { e.preventDefault(); if (!commentName.trim() || !commentText.trim()) return; const newComment: Comment = { id: `comment-${Date.now()}`, author: commentName, date: new Date().toLocaleDateString('hi-IN'), text: commentText }; const currentBlogComments = commentsList[blogId] || activeBlog?.comments || []; setCommentsList({ ...commentsList, [blogId]: [newComment, ...currentBlogComments] }); setCommentName(''); setCommentText(''); setCommentSuccess(true); setTimeout(() => setCommentSuccess(false), 3000); }; const getCommentsForBlog = (blogId: string) => { return commentsList[blogId] || blogs.find(b => b.id === blogId)?.comments || []; }; const filteredBlogs = activeCategory === 'All' ? blogs : blogs.filter(b => b.category === activeCategory); // READ SINGLE POST VIEW if (activeBlog && activeAuthor) { const postComments = getCommentsForBlog(activeBlog.id); return (

{/* Back button */} {/* Article Header */}
{activeBlog.category} Buying Guide

{activeBlog.titleHindi}

English: {activeBlog.title}

{activeAuthor.name} {activeAuthor.nameHindi}
{new Date(activeBlog.publishedAt).toLocaleDateString('hi-IN', { year: 'numeric', month: 'long', day: 'numeric' })} 5 mins read
{/* Hero Banner Image */}
{activeBlog.title}
{/* Article Content */}
{activeBlog.content.split('\n\n').map((paragraph, idx) => { if (paragraph.startsWith('###')) { return (

{paragraph.replace('###', '').trim()}

); } if (paragraph.startsWith('*')) { // List items or mini block details return (
{paragraph.split('\n').map((line, lIdx) => (

{line.replace('*', '').trim()}

))}
); } return

{paragraph}

; })}
{/* Tags */}
{activeBlog.tags.map(tag => ( #{tag} ))}
{/* Author Box Signature */}
{activeAuthor.name}

लेखक: {activeAuthor.nameHindi}

{activeAuthor.bioHindi}

{/* Comments Segment */}

टिप्पणियां ({postComments.length})

{/* Comment Form */}
handleCommentSubmit(e, activeBlog.id)} className="p-6 rounded-2xl bg-white dark:bg-slate-950 border border-slate-200/60 dark:border-slate-850 space-y-4 shadow-sm">

एक टिप्पणी छोड़ें (Leave a Comment)

setCommentName(e.target.value)} placeholder="अपना नाम दर्ज करें (Your name)..." className="w-full px-4 py-2 border border-slate-200 dark:border-slate-800 rounded-xl bg-slate-50 dark:bg-slate-900 text-xs focus:outline-none focus:border-amber-500 focus:bg-white transition-all" />
{commentSuccess && (

आपकी टिप्पणी सफलतापूर्वक जोड़ दी गई है!

)}
{/* Comment list */}
{postComments.length === 0 ? (

इस लेख पर अभी कोई टिप्पणी नहीं है। पहली टिप्पणी लिखें!

) : ( postComments.map((comment) => (
{comment.author} {comment.date}

{comment.text}

)) )}
); } // STANDARD LIST VIEW return (
{/* Title */}
expert purchase guides

हमारे ख़ास ख़रीदारी ब्लॉग्स (Expert Buying Guides)

विस्तृत स्पेसिफिकेशन विश्लेषण, मूल्य तुलना और भारतीय बाज़ार के अनुसार सर्वोत्तम निर्णय गाइड।

{/* Categories tag filter pill row */}
{blogCategories.map(cat => ( ))}
{/* Blog Post Cards Grid */}
{filteredBlogs.map(blog => { const author = authors.find(a => a.id === blog.authorId); return (
setSelectedBlogId(blog.id)} className="group bg-white/80 dark:bg-slate-900/40 backdrop-blur-md rounded-3xl border border-slate-200/50 dark:border-white/5 overflow-hidden luxury-shadow hover-premium cursor-pointer flex flex-col h-full" >
{blog.title} {blog.category}

{blog.titleHindi}

{blog.intro}

{author?.nameHindi || 'Editor'} 5 mins read
); })}
); }

Ignite Your Style

Our mission is to bring you the freshest insights into the world of fashion, from the hottest runway trends to the most coveted street style looks.

Never miss a beat when it comes to fashion

[mc4wp_form]
©Foxiz News Network. Ruby Design Company. All Rights Reserved.

Follow US