"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
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="shift-hover"
                defaultTextAnimation="entrance-slide"
                borderRadius="soft"
                contentWidth="smallMedium"
                sizing="largeSmall"
                background="floatingGradient"
                cardStyle="elevated"
                primaryButtonStyle="shadow"
                secondaryButtonStyle="solid"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarLayoutFloatingInline
                            brandName="Brew Haven"
                            navItems={[
                                { name: "Home", id: "hero" },
                                { name: "About", id: "about" },
                                { name: "Menu", id: "products" },
                                { name: "Contact", id: "contact" }
                            ]}
                            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: "Home", href: "#hero" },
                                        { label: "About", href: "#about" },
                                        { label: "Menu", href: "#products" },
                                        { label: "Contact", href: "#contact" }
                                    ]
                                },
                                {
                                    title: "Connect",                                    items: [
                                        { label: "Instagram", href: "https://instagram.com" },
                                        { label: "Facebook", href: "https://facebook.com" },
                                        { label: "Twitter", href: "https://twitter.com" },
                                        { label: "Email", href: "mailto:hello@brewhaven.com" }
                                    ]
                                },
                                {
                                    title: "Hours",                                    items: [
                                        { label: "Monday - Friday: 6 AM - 8 PM", href: "#" },
                                        { label: "Saturday - Sunday: 7 AM - 9 PM", href: "#" },
                                        { label: "Closed Holidays", href: "#" }
                                    ]
                                },
                                {
                                    title: "Legal",                                    items: [
                                        { label: "Privacy Policy", href: "#" },
                                        { label: "Terms of Service", href: "#" }
                                    ]
                                }
                            ]}
                            bottomLeftText="© 2025 Brew Haven. All rights reserved."
                            bottomRightText="Crafted with ☕ and passion"
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="smallMedium"
            sizing="largeSmall"
            background="floatingGradient"
            cardStyle="elevated"
            primaryButtonStyle="shadow"
            secondaryButtonStyle="solid"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarLayoutFloatingInline
                        brandName="Brew Haven"
                        navItems={[
                            { name: "Home", id: "hero" },
                            { name: "About", id: "about" },
                            { name: "Menu", id: "products" },
                            { name: "Contact", id: "contact" }
                        ]}
                        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: "Home", href: "#hero" },
                                    { label: "About", href: "#about" },
                                    { label: "Menu", href: "#products" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "Facebook", href: "https://facebook.com" },
                                    { label: "Twitter", href: "https://twitter.com" },
                                    { label: "Email", href: "mailto:hello@brewhaven.com" }
                                ]
                            },
                            {
                                title: "Hours",                                items: [
                                    { label: "Monday - Friday: 6 AM - 8 PM", href: "#" },
                                    { label: "Saturday - Sunday: 7 AM - 9 PM", href: "#" },
                                    { label: "Closed Holidays", href: "#" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 Brew Haven. All rights reserved."
                        bottomRightText="Crafted with ☕ and passion"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
