"use client";

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

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="hover-magnetic"
                defaultTextAnimation="entrance-slide"
                borderRadius="pill"
                contentWidth="compact"
                sizing="largeSmallSizeLargeTitles"
                background="floatingGradient"
                cardStyle="layered-gradient"
                primaryButtonStyle="double-inset"
                secondaryButtonStyle="solid"
                headingFontWeight="extrabold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarLayoutFloatingInline
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "Shop", id: "/shop" },
                            ]}
                            brandName="Grand Stay"
                            button={{ text: "Cart", onClick: () => {} }}
                        />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="compact"
            sizing="largeSmallSizeLargeTitles"
            background="floatingGradient"
            cardStyle="layered-gradient"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="solid"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarLayoutFloatingInline
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" },
                        ]}
                        brandName="Grand Stay"
                        button={{ text: "Cart", onClick: () => {} }}
                    />
                </div>
                <div id="product-catalog" data-section="product-catalog">
                    <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: "Hotel",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Rooms", href: "#rooms" },
                                    { label: "Amenities", href: "#amenities" },
                                ],
                            },
                            {
                                title: "Guest Services",                                items: [
                                    { label: "FAQ", href: "#faq" },
                                    { label: "Contact Us", href: "#contact" },
                                    { label: "Privacy Policy", href: "/privacy" },
                                ],
                            },
                            {
                                title: "Follow Us",                                items: [
                                    { label: "Facebook", href: "https://facebook.com/grandstay" },
                                    { label: "Instagram", href: "https://instagram.com/grandstay" },
                                    { label: "Twitter", href: "https://twitter.com/grandstay" },
                                ],
                            },
                        ]}
                        copyrightText="© 2024 Grand Stay. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
