'use client'; import { useEffect, useState } from 'react'; import { useRouter } from 'next/navigation'; import Link from 'next/link'; import { X, Package, Video, Radio, BookOpen, Sparkles, ShoppingBag, ChevronLeft } from 'lucide-react'; import { useAuth } from '@/components/auth-provider'; import { PageSkeleton } from '@/components/page-skeleton'; import { API_BASE } from '@/lib/api'; export default function CreatePage() { const { user, loading: authLoading } = useAuth(); const router = useRouter(); const [isSeller, setIsSeller] = useState(false); const [checking, setChecking] = useState(true); useEffect(() => { if (!authLoading && !user) { router.push('/login?next=/create'); return; } if (user) { (async () => { try { const resp = await fetch(`${API_BASE}/api/seller-profile`, { credentials: 'include', method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ op: 'get' }), }); if (resp.ok) { const data = await resp.json(); if (data.success && data.seller) { setIsSeller(true); } } } catch {} setChecking(false); })(); } }, [user, authLoading, router]); if (authLoading || checking) { return ( ); } // Buyer create options (limited) const buyerOptions = [ { href: '/ai-chat', icon: Sparkles, label: 'Ask AI', desc: 'Find products with AI' }, { href: '/become-seller', icon: Package, label: 'Become a Seller', desc: 'Start your store' }, ]; // Seller create options (full) const sellerOptions = [ { href: '/seller/products', icon: Package, label: 'Add Product', desc: 'List a new product' }, { href: '/seller/videos', icon: Video, label: 'Post Video', desc: 'Showcase a product' }, { href: '/seller/go-live', icon: Radio, label: 'Go Live', desc: 'Start a live session' }, { href: '/seller/stories', icon: BookOpen, label: 'Post Story', desc: '24h story post' }, ]; const options = isSeller ? sellerOptions : buyerOptions; return (
{/* Top bar */}

Create

{!isSeller && (

Want to sell? Become a seller to unlock product posting, live streaming, and more.

Become a Seller
)} {options.map((opt) => { const Icon = opt.icon; return (
{opt.label}
{opt.desc}
); })}
); }