"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen';
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="directional-hover"
                defaultTextAnimation="background-highlight"
                borderRadius="rounded"
                contentWidth="smallMedium"
                sizing="largeSmall"
                background="circleGradient"
                cardStyle="gradient-mesh"
                primaryButtonStyle="flat"
                secondaryButtonStyle="solid"
                headingFontWeight="extrabold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleFullscreen
                            brandName="Sababa Kitchen"
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "About", id: "about" },
                                { name: "Menu", id: "/menu" },
                                { name: "Team", id: "team" },
                                { name: "Contact", id: "contact" }
                            ]}
                            bottomLeftText="Tel Aviv, Israel"
                            bottomRightText="reservations@sababa.com"
                        />
                    </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: "Home", href: "/" },
                                        { label: "About", href: "about" },
                                        { label: "Menu", href: "/menu" },
                                        { label: "Team", href: "team" }
                                    ]
                                },
                                {
                                    title: "Contact",                                    items: [
                                        { label: "Reservations", href: "tel:+972-3-123-4567" },
                                        { label: "Email", href: "mailto:reservations@sababa.com" },
                                        { label: "Location", href: "#" },
                                        { label: "Hours", href: "#" }
                                    ]
                                },
                                {
                                    title: "Discover",                                    items: [
                                        { label: "Our Story", href: "about" },
                                        { label: "Chef's Menu", href: "/menu" },
                                        { label: "Events", href: "#" },
                                        { label: "Catering", href: "#" }
                                    ]
                                }
                            ]}
                            bottomLeftText="© 2025 Sababa Kitchen. All rights reserved."
                            bottomRightText="Made with culinary passion"
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="smallMedium"
            sizing="largeSmall"
            background="circleGradient"
            cardStyle="gradient-mesh"
            primaryButtonStyle="flat"
            secondaryButtonStyle="solid"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="Sababa Kitchen"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Menu", id: "/menu" },
                            { name: "Team", id: "team" },
                            { name: "Contact", id: "contact" }
                        ]}
                        bottomLeftText="Tel Aviv, Israel"
                        bottomRightText="reservations@sababa.com"
                    />
                </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: "Home", href: "/" },
                                    { label: "About", href: "about" },
                                    { label: "Menu", href: "/menu" },
                                    { label: "Team", href: "team" }
                                ]
                            },
                            {
                                title: "Contact",                                items: [
                                    { label: "Reservations", href: "tel:+972-3-123-4567" },
                                    { label: "Email", href: "mailto:reservations@sababa.com" },
                                    { label: "Location", href: "#" },
                                    { label: "Hours", href: "#" }
                                ]
                            },
                            {
                                title: "Discover",                                items: [
                                    { label: "Our Story", href: "about" },
                                    { label: "Chef's Menu", href: "/menu" },
                                    { label: "Events", href: "#" },
                                    { label: "Catering", href: "#" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 Sababa Kitchen. All rights reserved."
                        bottomRightText="Made with culinary passion"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
