import { useState } from "react"; import { useQuery } from "@tanstack/react-query"; import { productsApi, categoriesApi, storesApi } from "@/lib/api"; import logoUrl from "@assets/assets_task_01k3qp9hccec89tp5ht8ee88x5_1756363038_img_1-removebg-preview (1)_1756364677577.png"; import Header from "@/components/layout/header"; import CategoryNav from "@/components/category/category-nav"; import ProductGrid from "@/components/product/product-grid"; import StoreCard from "@/components/store/store-card"; import { Button } from "@/components/ui/button"; import { Skeleton } from "@/components/ui/skeleton"; import { Category, Product, Store } from "@/types"; import { Package, ShieldCheck, Star, Truck, CreditCard, HeadphonesIcon } from "lucide-react"; import { LoadingSpinner } from "@/components/ui/spinner"; export default function Home() { const [searchQuery, setSearchQuery] = useState(""); const [selectedCategory, setSelectedCategory] = useState(""); const { data: categories = [], isLoading: categoriesLoading } = useQuery({ queryKey: ['/api/categories'], queryFn: () => categoriesApi.getAll(), }); const { data: featuredProducts = [], isLoading: featuredLoading } = useQuery({ queryKey: ['/api/products/featured'], queryFn: () => productsApi.getFeatured(), }); const { data: stores = [], isLoading: storesLoading } = useQuery({ queryKey: ['/api/stores'], queryFn: () => storesApi.getAll(), }); const { data: searchResults = [], isLoading: searchLoading } = useQuery({ queryKey: ['/api/products', { search: searchQuery, category: selectedCategory }], queryFn: () => productsApi.getAll({ ...(searchQuery && { search: searchQuery }), ...(selectedCategory && { category: selectedCategory }) }), enabled: !!(searchQuery || selectedCategory), }); const showingResults = searchQuery || selectedCategory; const displayProducts = showingResults ? searchResults : featuredProducts; const isProductsLoading = showingResults ? searchLoading : featuredLoading; return (
{/* Hero Section - Modern Style */}
{/* Hero Banner Card - Modern Style */}
Shoposphere

Discover Amazing Products
from trusted sellers

Fast Delivery

Get your orders delivered quickly

{/* Category Navigation */}
{categoriesLoading ? (
{[...Array(6)].map((_, i) => (
))}
) : ( )}
{/* Products Section */}

{showingResults ? 'Search Results' : 'Featured Products'}

{showingResults ? `${displayProducts.length} products found` : 'Discover our handpicked selection of the best products from trusted sellers' }

{isProductsLoading ? (
{[...Array(12)].map((_, i) => (
))}
) : ( )}
{/* All Stores Section */}

All Stores

Explore our network of verified sellers and their unique collections

{storesLoading ? (
{[...Array(6)].map((_, i) => (
))}
) : stores.length > 0 ? (
{stores.map((store: Store) => ( ))}
) : (

No stores available at the moment.

)}
); }