"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
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="slide-background"
                defaultTextAnimation="entrance-slide"
                borderRadius="soft"
                contentWidth="medium"
                sizing="mediumSizeLargeTitles"
                background="fluid"
                cardStyle="gradient-bordered"
                primaryButtonStyle="inset-glow"
                secondaryButtonStyle="glass"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleApple
                            brandName="Luxe Haven"
                            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":"Navigate","items":[{"label":"Rooms","href":"#rooms"},{"label":"Amenities","href":"#amenities"},{"label":"About","href":"#about"}]},
                                {"title":"Guest Services","items":[{"label":"Reservations","href":"#"},{"label":"Concierge","href":"#"},{"label":"Room Service","href":"#"}]},
                                {"title":"Information","items":[{"label":"Policies","href":"#"},{"label":"Careers","href":"#"},{"label":"Contact","href":"#"}]}
                            ]}
                            bottomLeftText="© 2025 Luxe Haven Resort. All rights reserved."
                            bottomRightText="Designed for luxury travel experiences"
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="slide-background"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="medium"
            sizing="mediumSizeLargeTitles"
            background="fluid"
            cardStyle="gradient-bordered"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleApple
                        brandName="Luxe Haven"
                        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":"Navigate","items":[{"label":"Rooms","href":"#rooms"},{"label":"Amenities","href":"#amenities"},{"label":"About","href":"#about"}]},
                            {"title":"Guest Services","items":[{"label":"Reservations","href":"#"},{"label":"Concierge","href":"#"},{"label":"Room Service","href":"#"}]},
                            {"title":"Information","items":[{"label":"Policies","href":"#"},{"label":"Careers","href":"#"},{"label":"Contact","href":"#"}]}
                        ]}
                        bottomLeftText="© 2025 Luxe Haven Resort. All rights reserved."
                        bottomRightText="Designed for luxury travel experiences"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}