"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen';
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="hover-bubble"
                defaultTextAnimation="entrance-slide"
                borderRadius="soft"
                contentWidth="compact"
                sizing="mediumLargeSizeLargeTitles"
                background="floatingGradient"
                cardStyle="gradient-mesh"
                primaryButtonStyle="flat"
                secondaryButtonStyle="solid"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"Shop","id":"products"},
                            {"name":"About","id":"about"},
                            {"name":"Reviews","id":"reviews"},
                            {"name":"Contact","id":"contact"}
                        ]}
                        brandName="Luxe"
                        bottomLeftText="Premium Products"
                        bottomRightText="support@luxe.com"
                    />
                    </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":"Shop","items":[{"label":"Products","href":"products"},{"label":"Collections","href":"collections"},{"label":"Sale","href":"sale"},{"label":"New Arrivals","href":"new"}]},
                            {"title":"Support","items":[{"label":"Contact Us","href":"contact"},{"label":"Shipping Info","href":"shipping"},{"label":"Returns","href":"returns"},{"label":"FAQ","href":"faq"}]},
                            {"title":"Company","items":[{"label":"About Us","href":"about"},{"label":"Privacy Policy","href":"privacy"},{"label":"Terms & Conditions","href":"terms"},{"label":"Careers","href":"careers"}]}
                        ]}
                        copyrightText="© 2025 Luxe Collection. All rights reserved."
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="hover-bubble"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="compact"
            sizing="mediumLargeSizeLargeTitles"
            background="floatingGradient"
            cardStyle="gradient-mesh"
            primaryButtonStyle="flat"
            secondaryButtonStyle="solid"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleFullscreen
                    navItems={[
                        {"name":"Home","id":"/"},
                        {"name":"Shop","id":"products"},
                        {"name":"About","id":"about"},
                        {"name":"Reviews","id":"reviews"},
                        {"name":"Contact","id":"contact"}
                    ]}
                    brandName="Luxe"
                    bottomLeftText="Premium Products"
                    bottomRightText="support@luxe.com"
                />
                </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":"Shop","items":[{"label":"Products","href":"products"},{"label":"Collections","href":"collections"},{"label":"Sale","href":"sale"},{"label":"New Arrivals","href":"new"}]},
                        {"title":"Support","items":[{"label":"Contact Us","href":"contact"},{"label":"Shipping Info","href":"shipping"},{"label":"Returns","href":"returns"},{"label":"FAQ","href":"faq"}]},
                        {"title":"Company","items":[{"label":"About Us","href":"about"},{"label":"Privacy Policy","href":"privacy"},{"label":"Terms & Conditions","href":"terms"},{"label":"Careers","href":"careers"}]}
                    ]}
                    copyrightText="© 2025 Luxe Collection. All rights reserved."
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}