"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import FooterLogoEmphasis from '@/components/sections/footer/FooterLogoEmphasis';
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="elastic-effect"
                defaultTextAnimation="background-highlight"
                borderRadius="rounded"
                contentWidth="mediumSmall"
                sizing="largeSizeMediumTitles"
                background="blurBottom"
                cardStyle="gradient-mesh"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="radial-glow"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleApple
                            brandName="Brother's Barber Shop"
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "Shop", id: "/shop" }
                            ]}
                            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">
                        <FooterLogoEmphasis
                            logoText="Brother's Barber Shop"
                            columns={[
                                {
                                    items: [
                                        { label: "Services", href: "#services" },
                                        { label: "Team", href: "#team" },
                                        { label: "About", href: "#about" }
                                    ]
                                },
                                {
                                    items: [
                                        { label: "Testimonials", href: "#testimonials" },
                                        { label: "FAQ", href: "#faq" },
                                        { label: "Contact", href: "#contact" }
                                    ]
                                },
                                {
                                    items: [
                                        { label: "Instagram", href: "https://instagram.com" },
                                        { label: "Facebook", href: "https://facebook.com" },
                                        { label: "Google Reviews", href: "https://google.com" }
                                    ]
                                }
                            ]}
                            ariaLabel="Site footer"
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="mediumSmall"
            sizing="largeSizeMediumTitles"
            background="blurBottom"
            cardStyle="gradient-mesh"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleApple
                        brandName="Brother's Barber Shop"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        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">
                    <FooterLogoEmphasis
                        logoText="Brother's Barber Shop"
                        columns={[
                            {
                                items: [
                                    { label: "Services", href: "#services" },
                                    { label: "Team", href: "#team" },
                                    { label: "About", href: "#about" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Testimonials", href: "#testimonials" },
                                    { label: "FAQ", href: "#faq" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "Facebook", href: "https://facebook.com" },
                                    { label: "Google Reviews", href: "https://google.com" }
                                ]
                            }
                        ]}
                        ariaLabel="Site footer"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}