'use client'; import { useEffect, useState } from 'react'; import { api, formatPrice } from '@/lib/api'; import { Radio, Eye, ChevronLeft, Store } from 'lucide-react'; import Link from 'next/link'; import { useRouter } from 'next/navigation'; import { EmptyState } from '@/components/product-card'; import { PageSkeleton } from '@/components/page-skeleton'; export default function LivePage() { const router = useRouter(); const [liveNow, setLiveNow] = useState([]); const [recent, setRecent] = useState([]); const [loading, setLoading] = useState(true); useEffect(() => { (async () => { const [liveResp, recentResp] = await Promise.all([ api.live.list('live'), api.live.list('ended'), ]); if (liveResp.success) setLiveNow(liveResp.sessions || []); if (recentResp.success) setRecent(recentResp.sessions || []); setLoading(false); })(); }, []); if (loading) { return ; } return (
{/* Top bar */}

Live Shopping

{/* Live Now */}

LIVE NOW ({liveNow.length})

{liveNow.length === 0 ? (

No live sessions right now

Check back later or follow your favorite sellers

) : (
{liveNow.map((s) => (
LIVE
{s.viewer_count || 0}

{s.title}

{(s.seller_name || 'S').charAt(0)}
{s.seller_name}
{s.featured_product && (
{s.featured_product.name} {formatPrice(s.featured_product.price)}
)}
))}
)}
{/* Recent */} {recent.length > 0 && (

Recent Sessions

{recent.slice(0, 6).map((s) => (

{s.title}

{s.seller_name}
))}
)} {liveNow.length === 0 && recent.length === 0 && (
} title="No live sessions yet" message="Sellers can go live to showcase their products in real-time. Follow sellers to get notified when they go live." action={ } />
)}
); }