"use client";

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

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="expand-hover"
                defaultTextAnimation="background-highlight"
                borderRadius="pill"
                contentWidth="compact"
                sizing="large"
                background="circleGradient"
                cardStyle="gradient-radial"
                primaryButtonStyle="double-inset"
                secondaryButtonStyle="layered"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        brandName="Moys"
                        bottomLeftText="Near OSU Campus • Cozy Seating"
                        bottomRightText="Call for Reservations"
                        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">
                    <FooterLogoReveal
                        logoText="Moys"
                        leftLink={{ text: "Hours & Location", href: "#visit" }}
                        rightLink={{ text: "Call (614) 291-MOYS", href: "tel:+16142916699" }}
                        ariaLabel="Moys Chinese Restaurant footer"
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="expand-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="compact"
            sizing="large"
            background="circleGradient"
            cardStyle="gradient-radial"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleFullscreen
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    brandName="Moys"
                    bottomLeftText="Near OSU Campus • Cozy Seating"
                    bottomRightText="Call for Reservations"
                    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">
                <FooterLogoReveal
                    logoText="Moys"
                    leftLink={{ text: "Hours & Location", href: "#visit" }}
                    rightLink={{ text: "Call (614) 291-MOYS", href: "tel:+16142916699" }}
                    ariaLabel="Moys Chinese Restaurant footer"
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}