"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="text-stagger"
                defaultTextAnimation="reveal-blur"
                borderRadius="pill"
                contentWidth="smallMedium"
                sizing="medium"
                background="aurora"
                cardStyle="layered-gradient"
                primaryButtonStyle="flat"
                secondaryButtonStyle="radial-glow"
                headingFontWeight="semibold"
            >
                <ReactLenis root>
                    <NavbarStyleCentered
                        brandName="Globus"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        button={{ text: "Shop Now", href: "/shop" }}
                    />
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <FooterBaseReveal
                        columns={[
                            {
                                title: "Products",                                items: [
                                    { label: "All Cups", href: "/shop" },
                                    { label: "Collections", href: "/shop" },
                                    { label: "New Arrivals", href: "/shop" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "/" },
                                    { label: "Sustainability", href: "/" },
                                    { label: "Careers", href: "/" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Contact Us", href: "/contacts" },
                                    { label: "Shipping Info", href: "/" },
                                    { label: "Returns", href: "/" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Globus Cups | Premium Drinkware Since 2010"
                    />
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="reveal-blur"
            borderRadius="pill"
            contentWidth="smallMedium"
            sizing="medium"
            background="aurora"
            cardStyle="layered-gradient"
            primaryButtonStyle="flat"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <NavbarStyleCentered
                    brandName="Globus"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    button={{ text: "Shop Now", href: "/shop" }}
                />
                <ProductCatalog
                    layout="page"
                    products={products}
                    searchValue={search}
                    onSearchChange={setSearch}
                    searchPlaceholder="Search products..."
                    filters={filters}
                    emptyMessage="No products found"
                />
                <FooterBaseReveal
                    columns={[
                        {
                            title: "Products",                            items: [
                                { label: "All Cups", href: "/shop" },
                                { label: "Collections", href: "/shop" },
                                { label: "New Arrivals", href: "/shop" }
                            ]
                        },
                        {
                            title: "Company",                            items: [
                                { label: "About Us", href: "/" },
                                { label: "Sustainability", href: "/" },
                                { label: "Careers", href: "/" }
                            ]
                        },
                        {
                            title: "Support",                            items: [
                                { label: "Contact Us", href: "/contacts" },
                                { label: "Shipping Info", href: "/" },
                                { label: "Returns", href: "/" }
                            ]
                        }
                    ]}
                    copyrightText="© 2025 Globus Cups | Premium Drinkware Since 2010"
                />
            </ReactLenis>
        </ThemeProvider>
    );
}