import { useQuery } from '@tanstack/react-query'; import { Link } from '@tanstack/react-router'; import { fetchPinnedLiveBlogs } from '@/lib/api'; import { Button } from '@/components/ui/button'; import { Calendar, Eye, MessageSquare, Pin } from 'lucide-react'; export function PinnedLiveBlogsSidebar() { const { data: liveBlogs, isLoading, error } = useQuery({ queryKey: ['pinned-live-blogs'], queryFn: fetchPinnedLiveBlogs, }); const getStatusBadge = (status: string) => { switch (status) { case 'live': return ( LIVE ); case 'ended': return ( ENDED ); case 'archived': return ( ARCHIVED ); default: return ( DRAFT ); } }; const formatDate = (dateString: string) => { const date = new Date(dateString); return date.toLocaleDateString('mk-MK', { day: 'numeric', month: 'short', }); }; if (isLoading) { return (

Pinned Live

{[1, 2, 3].map((i) => (
))}
); } if (error) { return (

Pinned Live

ERROR
); } if (!liveBlogs || liveBlogs.length === 0) { return (

Pinned Live

No pinned live blogs

Pin live blogs from the admin panel.

); } return (

Pinned Live

{liveBlogs.length}
{liveBlogs.map((liveBlog) => (

{liveBlog.title}

{getStatusBadge(liveBlog.status)}
{liveBlog.description && (

{liveBlog.description}

)}
{formatDate(liveBlog.createdAt)}
{liveBlog.viewCount}
{liveBlog.updates && liveBlog.updates.length > 0 && (
{liveBlog.updates.length}
)} {liveBlog.author && (
{liveBlog.author.name}
)}
{liveBlog.featuredImage && (
{liveBlog.title}
)}
))}
); }