"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen';
import FooterBaseCard from '@/components/sections/footer/FooterBaseCard';
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="text-shift"
                defaultTextAnimation="entrance-slide"
                borderRadius="rounded"
                contentWidth="medium"
                sizing="mediumLargeSizeMediumTitles"
                background="aurora"
                cardStyle="subtle-shadow"
                primaryButtonStyle="double-inset"
                secondaryButtonStyle="glass"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleFullscreen
                            brandName="Prime Cut"
                            navItems={[
                                {"name":"Home","id":"/"},
                                {"name":"Shop","id":"/shop"}
                            ]}
                            bottomLeftText="New York, NY"
                            bottomRightText="reservations@primecut.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>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-shift"
            defaultTextAnimation="entrance-slide"
            borderRadius="rounded"
            contentWidth="medium"
            sizing="mediumLargeSizeMediumTitles"
            background="aurora"
            cardStyle="subtle-shadow"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="glass"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="Prime Cut"
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"Shop","id":"/shop"}
                        ]}
                        bottomLeftText="New York, NY"
                        bottomRightText="reservations@primecut.com"
                        button={{ text: "Cart", onClick: () => setCartOpen(true) }}
                    />
                </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">
                    <FooterBaseCard
                        logoText="Prime Cut"
                        copyrightText="© 2025 Prime Cut Steakhouse. All rights reserved."
                        columns={[
                            {
                                "title":"Restaurant",                                "items":[
                                    {"label":"About Us","href":"#about"},
                                    {"label":"Menu","href":"#features"},
                                    {"label":"Experiences","href":"#experience"},
                                    {"label":"Reviews","href":"#testimonials"}
                                ]
                            },
                            {
                                "title":"Dining",                                "items":[
                                    {"label":"Make Reservation","href":"#contact"},
                                    {"label":"Private Events","href":"#contact"},
                                    {"label":"Gift Cards","href":"#"},
                                    {"label":"Wine Cellar","href":"#experience"}
                                ]
                            },
                            {
                                "title":"Company",                                "items":[
                                    {"label":"Contact","href":"#contact"},
                                    {"label":"FAQ","href":"#faq"},
                                    {"label":"Careers","href":"#"},
                                    {"label":"Blog","href":"#"}
                                ]
                            },
                            {
                                "title":"Legal",                                "items":[
                                    {"label":"Privacy Policy","href":"#"},
                                    {"label":"Terms of Service","href":"#"},
                                    {"label":"Cookie Policy","href":"#"}
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}