"use client";

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

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

    const [cartOpen, setCartOpen] = useState(false);

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="slide-background"
                defaultTextAnimation="background-highlight"
                borderRadius="pill"
                contentWidth="mediumLarge"
                sizing="largeSmallSizeLargeTitles"
                background="circleGradient"
                cardStyle="gradient-bordered"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="solid"
                headingFontWeight="light"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleFullscreen
                            brandName="Luxury Hotel"
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "Shop", id: "/shop" },
                                { name: "Contact", id: "contact" }
                            ]}
                            bottomLeftText="Premium Hospitality"
                            bottomRightText="reservations@luxuryhotel.com"
                            button={{ text: "Cart", onClick: () => setCartOpen(true) }}
                        />
                    </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">
                        <FooterBase
                            logoText="Luxury Hotel"
                            copyrightText="© 2025 Luxury Hotel. All rights reserved."
                            columns={[
                                {
                                    title: "Rooms",                                    items: [
                                        { label: "Deluxe Rooms", href: "rooms" },
                                        { label: "Suites", href: "rooms" },
                                        { label: "Penthouses", href: "rooms" }
                                    ]
                                },
                                {
                                    title: "Services",                                    items: [
                                        { label: "Restaurant", href: "amenities" },
                                        { label: "Spa & Wellness", href: "amenities" },
                                        { label: "Events & Meetings", href: "amenities" }
                                    ]
                                },
                                {
                                    title: "Information",                                    items: [
                                        { label: "About Us", href: "about" },
                                        { label: "Contact", href: "contact" }
                                    ]
                                }
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="slide-background"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="mediumLarge"
            sizing="largeSmallSizeLargeTitles"
            background="circleGradient"
            cardStyle="gradient-bordered"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="Luxury Hotel"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" },
                            { name: "Contact", id: "contact" }
                        ]}
                        bottomLeftText="Premium Hospitality"
                        bottomRightText="reservations@luxuryhotel.com"
                        button={{ text: "Cart", onClick: () => setCartOpen(true) }}
                    />
                </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">
                    <FooterBase
                        logoText="Luxury Hotel"
                        copyrightText="© 2025 Luxury Hotel. All rights reserved."
                        columns={[
                            {
                                title: "Rooms",                                items: [
                                    { label: "Deluxe Rooms", href: "rooms" },
                                    { label: "Suites", href: "rooms" },
                                    { label: "Penthouses", href: "rooms" }
                                ]
                            },
                            {
                                title: "Services",                                items: [
                                    { label: "Restaurant", href: "amenities" },
                                    { label: "Spa & Wellness", href: "amenities" },
                                    { label: "Events & Meetings", href: "amenities" }
                                ]
                            },
                            {
                                title: "Information",                                items: [
                                    { label: "About Us", href: "about" },
                                    { label: "Contact", href: "contact" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}