'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 (
Want to sell? Become a seller to unlock product posting, live streaming, and more.
Become a Seller