"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import FooterSimple from '@/components/sections/footer/FooterSimple';
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="shift-hover"
                defaultTextAnimation="reveal-blur"
                borderRadius="soft"
                contentWidth="mediumSmall"
                sizing="largeSizeMediumTitles"
                background="floatingGradient"
                cardStyle="subtle-shadow"
                primaryButtonStyle="radial-glow"
                secondaryButtonStyle="layered"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarLayoutFloatingInline
                            brandName="FitFlow"
                            navItems={[
                                {"name":"Home","id":"/"},
                                {"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">
                        <FooterSimple
                            columns={[
                                {"title":"Product","items":[{"label":"Features","href":"#features"},{"label":"Pricing","href":"#plans"},{"label":"Download","href":"#download"},{"label":"Security","href":"#"}]},
                                {"title":"Community","items":[{"label":"Stories","href":"#testimonials"},{"label":"Blog","href":"#"},{"label":"Events","href":"#"},{"label":"Support","href":"#"}]},
                                {"title":"Company","items":[{"label":"About","href":"#"},{"label":"Careers","href":"#"},{"label":"Contact","href":"#"},{"label":"Partners","href":"#"}]},
                                {"title":"Legal","items":[{"label":"Privacy","href":"#"},{"label":"Terms","href":"#"},{"label":"Cookies","href":"#"},{"label":"Accessibility","href":"#"}]}
                            ]}
                            bottomLeftText="© 2025 FitFlow. All rights reserved."
                            bottomRightText="Transform Your Fitness"
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="largeSizeMediumTitles"
            background="floatingGradient"
            cardStyle="subtle-shadow"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarLayoutFloatingInline
                        brandName="FitFlow"
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"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">
                    <FooterSimple
                        columns={[
                            {"title":"Product","items":[{"label":"Features","href":"#features"},{"label":"Pricing","href":"#plans"},{"label":"Download","href":"#download"},{"label":"Security","href":"#"}]},
                            {"title":"Community","items":[{"label":"Stories","href":"#testimonials"},{"label":"Blog","href":"#"},{"label":"Events","href":"#"},{"label":"Support","href":"#"}]},
                            {"title":"Company","items":[{"label":"About","href":"#"},{"label":"Careers","href":"#"},{"label":"Contact","href":"#"},{"label":"Partners","href":"#"}]},
                            {"title":"Legal","items":[{"label":"Privacy","href":"#"},{"label":"Terms","href":"#"},{"label":"Cookies","href":"#"},{"label":"Accessibility","href":"#"}]}
                        ]}
                        bottomLeftText="© 2025 FitFlow. All rights reserved."
                        bottomRightText="Transform Your Fitness"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}