"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";

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="text-shift"
                defaultTextAnimation="background-highlight"
                borderRadius="pill"
                contentWidth="mediumLarge"
                sizing="largeSmallSizeLargeTitles"
                background="circleGradient"
                cardStyle="elevated"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="layered"
                headingFontWeight="semibold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleFullscreen
                            brandName="Brew Haven"
                            navItems={[
                                {"name":"Home","id":"/"},
                                {"name":"About","id":"about"},
                                {"name":"Menu","id":"menu"},
                                {"name":"Team","id":"team"},
                                {"name":"Contact","id":"contact"},
                                {"name":"Shop","id":"/shop"}
                            ]}
                            bottomLeftText="Craft Coffee Culture"
                            bottomRightText="hello@brewhaven.com"
                            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">
                        <FooterBase
                            logoText="Brew Haven"
                            copyrightText="© 2025 Brew Haven. All rights reserved."
                            columns={[
                                {"title":"Menu","items":[{"label":"Coffee Drinks","href":"menu"},{"label":"Pastries","href":"menu"},{"label":"Seasonal Specials","href":"menu"}]},
                                {"title":"Company","items":[{"label":"About Us","href":"about"},{"label":"Our Team","href":"team"},{"label":"Contact","href":"contact"}]},
                                {"title":"Connect","items":[{"label":"Instagram","href":"https://instagram.com"},{"label":"Facebook","href":"https://facebook.com"},{"label":"Email","href":"https://mailto:hello@brewhaven.com"}]}
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-shift"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="mediumLarge"
            sizing="largeSmallSizeLargeTitles"
            background="circleGradient"
            cardStyle="elevated"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="Brew Haven"
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"About","id":"about"},
                            {"name":"Menu","id":"menu"},
                            {"name":"Team","id":"team"},
                            {"name":"Contact","id":"contact"},
                            {"name":"Shop","id":"/shop"}
                        ]}
                        bottomLeftText="Craft Coffee Culture"
                        bottomRightText="hello@brewhaven.com"
                        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">
                    <FooterBase
                        logoText="Brew Haven"
                        copyrightText="© 2025 Brew Haven. All rights reserved."
                        columns={[
                            {"title":"Menu","items":[{"label":"Coffee Drinks","href":"menu"},{"label":"Pastries","href":"menu"},{"label":"Seasonal Specials","href":"menu"}]},
                            {"title":"Company","items":[{"label":"About Us","href":"about"},{"label":"Our Team","href":"team"},{"label":"Contact","href":"contact"}]},
                            {"title":"Connect","items":[{"label":"Instagram","href":"https://instagram.com"},{"label":"Facebook","href":"https://facebook.com"},{"label":"Email","href":"https://mailto:hello@brewhaven.com"}]}
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}