"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingOverlay from '@/components/navbar/NavbarLayoutFloatingOverlay/NavbarLayoutFloatingOverlay';
import FooterMedia from '@/components/sections/footer/FooterMedia';
import ProductCatalog from "@/components/ecommerce/productCatalog/ProductCatalog";
import { useProductCatalog } from "@/hooks/useProductCatalog";

export default function ShopPage() {
    const {
        products,
        isLoading,
        search,
        setSearch,
        filters,
    } = useProductCatalog({ basePath: "/shop" });

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="shift-hover"
                defaultTextAnimation="background-highlight"
                borderRadius="rounded"
                contentWidth="smallMedium"
                sizing="mediumLargeSizeLargeTitles"
                background="aurora"
                cardStyle="solid"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="radial-glow"
                headingFontWeight="extrabold"
            >
                <ReactLenis root>
                    <div id="nav" data-section="nav">
                        <NavbarLayoutFloatingOverlay
                            brandName="Honey Bee"
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "Products", id: "products" },
                                { name: "About", id: "about" },
                                { name: "Contact", id: "contact" },
                                { name: "Shop", id: "/shop" }
                            ]}
                            button={{ text: "Shop Now", href: "products" }}
                        />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <FooterMedia
                        logoText="Honey Bee Cups"
                        imageSrc="https://img.b2bpic.net/free-photo/high-view-bowls-mugs-pottery-concept_23-2148679111.jpg"
                        imageAlt="Honey Bee Cups collection"
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "All Products", href: "products" },
                                    { label: "Featured Items", href: "products" },
                                    { label: "Gift Sets", href: "products" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "about" },
                                    { label: "Our Story", href: "about" },
                                    { label: "Contact", href: "contact" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "FAQs", href: "contact" },
                                    { label: "Shipping Info", href: "contact" },
                                    { label: "Care Guide", href: "contact" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Honey Bee Cups. All rights reserved."
                    />
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="smallMedium"
            sizing="mediumLargeSizeLargeTitles"
            background="aurora"
            cardStyle="solid"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Honey Bee"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Products", id: "products" },
                            { name: "About", id: "about" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        button={{ text: "Shop Now", href: "products" }}
                    />
                </div>
                <div id="productCatalog" data-section="productCatalog">
                    <ProductCatalog
                        layout="page"
                        products={products}
                        searchValue={search}
                        onSearchChange={setSearch}
                        searchPlaceholder="Search products..."
                        filters={filters}
                        emptyMessage="No products found"
                    />
                </div>
                <FooterMedia
                    logoText="Honey Bee Cups"
                    imageSrc="https://img.b2bpic.net/free-photo/high-view-bowls-mugs-pottery-concept_23-2148679111.jpg"
                    imageAlt="Honey Bee Cups collection"
                    columns={[
                        {
                            title: "Shop",                            items: [
                                { label: "All Products", href: "products" },
                                { label: "Featured Items", href: "products" },
                                { label: "Gift Sets", href: "products" }
                            ]
                        },
                        {
                            title: "Company",                            items: [
                                { label: "About Us", href: "about" },
                                { label: "Our Story", href: "about" },
                                { label: "Contact", href: "contact" }
                            ]
                        },
                        {
                            title: "Support",                            items: [
                                { label: "FAQs", href: "contact" },
                                { label: "Shipping Info", href: "contact" },
                                { label: "Care Guide", href: "contact" }
                            ]
                        }
                    ]}
                    copyrightText="© 2025 Honey Bee Cups. All rights reserved."
                />
            </ReactLenis>
        </ThemeProvider>
    );
}