'use client' import { useState } from 'react' import Header from '@/components/Header' import { RefreshCw, Loader2, Search, ExternalLink, Star, ShoppingCart } from 'lucide-react' import { useSettings } from '@/lib/context/SettingsContext' interface ShopProduct { id: string title: string url: string thumbnail: string price: number originalPrice: number discount: number soldCount: number rating: number reviewCount: number sellerName: string } const demoProducts: ShopProduct[] = [ { id: '1', title: 'Son Môi Tint 3 in 1 - Đa Năng', url: 'https://shop.tiktok.com/product/123', thumbnail: 'https://cdn3.dienthoaivui.com.vn/img/2024/10/25/8/1727146407-4f5b50f60bc2d1d19f2b4c5a6f8e9d1a-thumbnails.jpg', price: 89000, originalPrice: 150000, discount: 41, soldCount: 52000, rating: 4.5, reviewCount: 2300, sellerName: 'BeautyShopVN', }, { id: '2', title: 'Kính Râm Phong Cách Hàn Quốc', url: 'https://shop.tiktok.com/product/456', thumbnail: 'https://cdn3.dienthoaivui.com.vn/img/2024/10/25/8/1727146407-4f5b50f60bc2d1d19f2b4c5a6f8e9d1a-thumbnails.jpg', price: 159000, originalPrice: 299000, discount: 47, soldCount: 125000, rating: 4.8, reviewCount: 5100, sellerName: 'StyleKorea', }, { id: '3', title: 'Túi Xách Nữ Canvas Thời Trang', url: 'https://shop.tiktok.com/product/789', thumbnail: 'https://cdn3.dienthoaivui.com.vn/img/2024/10/25/8/1727146407-4f5b50f60bc2d1d19f2b4c5a6f8e9d1a-thumbnails.jpg', price: 249000, originalPrice: 450000, discount: 45, soldCount: 38000, rating: 4.2, reviewCount: 890, sellerName: 'FashionVN', }, { id: '4', title: 'Bông Tẩy Trang 3 Lớp Khổ Lớn', url: 'https://shop.tiktok.com/product/101', thumbnail: 'https://cdn3.dienthoaivui.com.vn/img/2024/10/25/8/1727146407-4f5b50f60bc2d1d19f2b4c5a6f8e9d1a-thumbnails.jpg', price: 35000, originalPrice: 59000, discount: 41, soldCount: 250000, rating: 4.9, reviewCount: 15000, sellerName: 'DailyBeauty', }, { id: '5', title: 'Bảng Màu Mắt 12 ô - Hot Trend', url: 'https://shop.tiktok.com/product/112', thumbnail: 'https://cdn3.dienthoaivui.com.vn/img/2024/10/25/8/1727146407-4f5b50f60bc2d1d19f2b4c5a6f8e9d1a-thumbnails.jpg', price: 199000, originalPrice: 350000, discount: 43, soldCount: 45000, rating: 4.6, reviewCount: 2800, sellerName: 'MakeupPro', }, { id: '6', title: 'Kem Dưỡng Ẩm Cấp Nước Hàn Quốc', url: 'https://shop.tiktok.com/product/131', thumbnail: 'https://cdn3.dienthoaivui.com.vn/img/2024/10/25/8/1727146407-4f5b50f60bc2d1d19f2b4c5a6f8e9d1a-thumbnails.jpg', price: 289000, originalPrice: 450000, discount: 36, soldCount: 180000, rating: 4.7, reviewCount: 9200, sellerName: 'SkinCareVN', }, ] function formatPrice(vnd: number): string { return new Intl.NumberFormat('vi-VN', { style: 'currency', currency: 'VND' }).format(vnd) } function formatSold(count: number): string { if (count >= 1000) return (count / 1000).toFixed(1) + 'K' return count.toString() } export default function ShopPage() { const { settings, isMounted } = useSettings() const [products, setProducts] = useState([]) const [isLoading, setIsLoading] = useState(false) const [searchQuery, setSearchQuery] = useState('') const [error, setError] = useState(null) if (!isMounted) { return (
Loading...
) } const handleFetchShop = async () => { if (!settings.tiktokCookies) { setError('Please configure TikTok cookies in Settings to fetch shop products') return } setIsLoading(true) setError(null) try { await new Promise(resolve => setTimeout(resolve, 1000)) setProducts(demoProducts) } catch (e: any) { setError(e.message || 'Failed to fetch shop products') } finally { setIsLoading(false) } } const filteredProducts = searchQuery ? products.filter(p => p.title.toLowerCase().includes(searchQuery.toLowerCase()) || p.sellerName.toLowerCase().includes(searchQuery.toLowerCase()) ) : products return (

TikTok Shop - Vietnam

Browse trending products with best sales

setSearchQuery(e.target.value)} placeholder="Search products..." className="w-full bg-surface border border-slate-600 rounded-lg pl-10 pr-4 py-2.5 text-white placeholder-slate-500 focus:outline-none focus:border-primary" />
{error && (
{error}
)} {filteredProducts.length > 0 ? (
{filteredProducts.map((product) => (
{product.title} {product.discount > 0 && (
-{product.discount}%
)}

{product.title}

{formatPrice(product.price)} {formatPrice(product.originalPrice)}
{product.rating} ({product.reviewCount})
{formatSold(product.soldCount)} sold
{product.sellerName} View
))}
) : (

No products loaded. Click "Refresh" to fetch trending products.

)}
) }