"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
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="bounce-effect"
                defaultTextAnimation="reveal-blur"
                borderRadius="rounded"
                contentWidth="smallMedium"
                sizing="largeSizeMediumTitles"
                background="blurBottom"
                cardStyle="gradient-mesh"
                primaryButtonStyle="diagonal-gradient"
                secondaryButtonStyle="glass"
                headingFontWeight="bold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleApple
                            brandName="Pepper Peak"
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "About", id: "/#about" },
                                { name: "Flavors", id: "/#flavors" },
                                { name: "Testimonials", id: "/#testimonials" },
                                { name: "Contact", id: "/#contact" },
                            ]}
                        />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="bounce-effect"
            defaultTextAnimation="reveal-blur"
            borderRadius="rounded"
            contentWidth="smallMedium"
            sizing="largeSizeMediumTitles"
            background="blurBottom"
            cardStyle="gradient-mesh"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="glass"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleApple
                        brandName="Pepper Peak"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "/#about" },
                            { name: "Flavors", id: "/#flavors" },
                            { name: "Testimonials", id: "/#testimonials" },
                            { name: "Contact", id: "/#contact" },
                        ]}
                    />
                </div>
                <div id="product-catalog" data-section="product-catalog">
                    <ProductCatalog
                        layout="page"
                        products={products}
                        searchValue={search}
                        onSearchChange={setSearch}
                        searchPlaceholder="Search products..."
                        filters={filters}
                        emptyMessage="No products found"
                    />
                </div>
                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/chili-sauce-peppers-dark-wooden-surface_1150-42161.jpg"
                        imageAlt="Hot sauce bottles background"
                        columns={[
                            { title: "Shop", items: [{ label: "Hot Sauces", href: "#flavors" }, { label: "Bundles", href: "/bundles" }, { label: "Merchandise", href: "/merch" }] },
                            { title: "Company", items: [{ label: "Our Story", href: "#about" }, { label: "FAQ", href: "#faq" }, { label: "Contact Us", href: "#contact" }] },
                            { title: "Legal", items: [{ label: "Privacy Policy", href: "/privacy" }, { label: "Terms of Service", href: "/terms" }] },
                        ]}
                        logoText="Pepper Peak"
                        copyrightText="© 2024 Pepper Peak. All rights reserved."
                        ariaLabel="Site footer with navigation and hot sauce imagery"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
