"use client";

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

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="directional-hover"
                defaultTextAnimation="entrance-slide"
                borderRadius="sharp"
                contentWidth="medium"
                sizing="largeSmallSizeLargeTitles"
                background="circleGradient"
                cardStyle="glass-depth"
                primaryButtonStyle="gradient"
                secondaryButtonStyle="glass"
                headingFontWeight="light"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleApple
                        brandName="Futurama"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Characters", id: "characters" },
                            { name: "Episodes", id: "episodes" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        button={{ text: "Cart", onClick: () => console.log("cart") }}
                    />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <div id="footer" data-section="footer">
                    <FooterBaseReveal
                        columns={[
                            {
                                title: "Watch",                                items: [
                                    { label: "Hulu", href: "https://www.hulu.com" },
                                    { label: "Disney+", href: "https://www.disneyplus.com" },
                                    { label: "Netflix", href: "https://www.netflix.com" },
                                    { label: "Amazon Prime", href: "https://www.primevideo.com" }
                                ]
                            },
                            {
                                title: "Community",                                items: [
                                    { label: "Fan Forum", href: "https://www.reddit.com/r/futurama" },
                                    { label: "Social Media", href: "https://www.twitter.com" },
                                    { label: "News", href: "#" },
                                    { label: "Events", href: "#" }
                                ]
                            },
                            {
                                title: "About",                                items: [
                                    { label: "The Show", href: "about" },
                                    { label: "Merchandise", href: "#" },
                                    { label: "Credits", href: "#" },
                                    { label: "Contact", href: "contact" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Futurama. All rights reserved. A creation of Matt Groening."
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="sharp"
            contentWidth="medium"
            sizing="largeSmallSizeLargeTitles"
            background="circleGradient"
            cardStyle="glass-depth"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="glass"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleApple
                    brandName="Futurama"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "About", id: "about" },
                        { name: "Characters", id: "characters" },
                        { name: "Episodes", id: "episodes" },
                        { name: "Contact", id: "contact" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    button={{ text: "Cart", onClick: () => console.log("cart") }}
                />
                </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>
                <div id="footer" data-section="footer">
                <FooterBaseReveal
                    columns={[
                        {
                            title: "Watch",                            items: [
                                { label: "Hulu", href: "https://www.hulu.com" },
                                { label: "Disney+", href: "https://www.disneyplus.com" },
                                { label: "Netflix", href: "https://www.netflix.com" },
                                { label: "Amazon Prime", href: "https://www.primevideo.com" }
                            ]
                        },
                        {
                            title: "Community",                            items: [
                                { label: "Fan Forum", href: "https://www.reddit.com/r/futurama" },
                                { label: "Social Media", href: "https://www.twitter.com" },
                                { label: "News", href: "#" },
                                { label: "Events", href: "#" }
                            ]
                        },
                        {
                            title: "About",                            items: [
                                { label: "The Show", href: "about" },
                                { label: "Merchandise", href: "#" },
                                { label: "Credits", href: "#" },
                                { label: "Contact", href: "contact" }
                            ]
                        }
                    ]}
                    copyrightText="© 2025 Futurama. All rights reserved. A creation of Matt Groening."
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}