"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered';
import FooterBaseReveal from '@/components/sections/footer/FooterBaseReveal';
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="elastic-effect"
                defaultTextAnimation="background-highlight"
                borderRadius="pill"
                contentWidth="compact"
                sizing="mediumSizeLargeTitles"
                background="noiseDiagonalGradient"
                cardStyle="gradient-radial"
                primaryButtonStyle="diagonal-gradient"
                secondaryButtonStyle="layered"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleCentered
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "About Us", id: "about" },
                                { name: "Services", id: "services" },
                                { name: "Case Studies", id: "product" },
                                { name: "Testimonials", id: "testimonials" },
                                { name: "FAQ", id: "faq" },
                                { name: "Contact", id: "contact" },
                                { name: "Shop", id: "/shop" }
                            ]}
                            brandName="Spike Media"
                            button={{ text: "Cart", onClick: () => {} }}
                        />
                    </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: "Services", items: [{ label: "Strategy", href: "services" }, { label: "Creation", href: "services" }, { label: "Management", href: "services" }] },
                                { title: "Company", items: [{ label: "About Us", href: "about" }, { label: "Case Studies", href: "product" }, { label: "Contact", href: "contact" }] },
                                { title: "Resources", items: [{ label: "FAQ", href: "faq" }, { label: "Testimonials", href: "testimonials" }] }
                            ]}
                            copyrightText="© 2024 Spike Media. All rights reserved."
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="compact"
            sizing="mediumSizeLargeTitles"
            background="noiseDiagonalGradient"
            cardStyle="gradient-radial"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleCentered
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About Us", id: "about" },
                            { name: "Services", id: "services" },
                            { name: "Case Studies", id: "product" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        brandName="Spike Media"
                        button={{ text: "Cart", onClick: () => {} }}
                    />
                </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">
                    <FooterBaseReveal
                        columns={[
                            { title: "Services", items: [{ label: "Strategy", href: "services" }, { label: "Creation", href: "services" }, { label: "Management", href: "services" }] },
                            { title: "Company", items: [{ label: "About Us", href: "about" }, { label: "Case Studies", href: "product" }, { label: "Contact", href: "contact" }] },
                            { title: "Resources", items: [{ label: "FAQ", href: "faq" }, { label: "Testimonials", href: "testimonials" }] }
                        ]}
                        copyrightText="© 2024 Spike Media. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
