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 - Enhanced Modern Style */}
{/* Hero Banner Card - Enhanced */}
{/* Background pattern */}
Shoposphere

Discover Amazing Products

from trusted sellers worldwide

Fast Delivery

Get your orders delivered quickly

{/* Category Navigation */}

Shop by Category

Find exactly what you're looking for

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

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

{showingResults ? `${displayProducts.length} products found` : 'Quality products from trusted sellers' }

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

🏪 Trusted Stores

Explore our network of verified sellers and their unique collections. Each store is carefully vetted to ensure quality and reliability.

Verified Sellers
Secure Payments
Quality Guaranteed
{storesLoading ? (
{[...Array(6)].map((_, i) => (
))}
) : stores.length > 0 ? (
{stores.map((store: Store) => ( ))}
) : (

No stores available at the moment.

)}
{/* Why Choose Shoposphere Section - Moved to Bottom */}

Why Choose Shoposphere?

Experience the best of online shopping with our premium features

Fast Delivery

Get your orders delivered quickly with our express shipping network

Secure Shopping

Your payments and personal data are protected with advanced security

24/7 Support

Our customer service team is always ready to help you

); }