"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered';
import ProductCatalog from "@/components/ecommerce/productCatalog/ProductCatalog";
import FooterBaseCard from '@/components/sections/footer/FooterBaseCard';
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="reveal-blur"
                borderRadius="sharp"
                contentWidth="mediumSmall"
                sizing="largeSmall"
                background="none"
                cardStyle="solid"
                primaryButtonStyle="inset-glow"
                secondaryButtonStyle="radial-glow"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleCentered
                            brandName="The Edge"
                            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">
                        <FooterBaseCard
                            logoText="The Edge"
                            columns={[
                                {
                                    title: "Services",                                    items: [
                                        { label: "Haircuts", href: "#services" },
                                        { label: "Beard Grooming", href: "#services" },
                                        { label: "Hot Towel Shave", href: "#services" },
                                        { label: "Kids Cuts", href: "#services" }
                                    ]
                                },
                                {
                                    title: "Company",                                    items: [
                                        { label: "About Us", href: "#about" },
                                        { label: "Pricing", href: "#pricing" },
                                        { label: "Reviews", href: "#testimonials" },
                                        { label: "FAQ", href: "#faq" }
                                    ]
                                },
                                {
                                    title: "Visit Us",                                    items: [
                                        { label: "123 Wynwood Ave, Miami, FL 33127", href: "https://maps.google.com" },
                                        { label: "(305) 555-EDGE", href: "tel:+13055553433" },
                                        { label: "Mon-Sat: 9AM - 7PM", href: "#" },
                                        { label: "Sun: 10AM - 5PM", href: "#" }
                                    ]
                                }
                            ]}
                            copyrightText="© 2025 The Edge Barber Shop. All rights reserved."
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-shift"
            defaultTextAnimation="reveal-blur"
            borderRadius="sharp"
            contentWidth="mediumSmall"
            sizing="largeSmall"
            background="none"
            cardStyle="solid"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleCentered
                        brandName="The Edge"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Services", id: "services" },
                            { name: "Reviews", id: "testimonials" },
                            { name: "Pricing", id: "pricing" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        button={{ text: "Cart", onClick: () => console.log("cart") }}
                    />
                </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="The Edge"
                        columns={[
                            {
                                title: "Services",                                items: [
                                    { label: "Haircuts", href: "#services" },
                                    { label: "Beard Grooming", href: "#services" },
                                    { label: "Hot Towel Shave", href: "#services" },
                                    { label: "Kids Cuts", href: "#services" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Pricing", href: "#pricing" },
                                    { label: "Reviews", href: "#testimonials" },
                                    { label: "FAQ", href: "#faq" }
                                ]
                            },
                            {
                                title: "Visit Us",                                items: [
                                    { label: "123 Wynwood Ave, Miami, FL 33127", href: "https://maps.google.com" },
                                    { label: "(305) 555-EDGE", href: "tel:+13055553433" },
                                    { label: "Mon-Sat: 9AM - 7PM", href: "#" },
                                    { label: "Sun: 10AM - 5PM", href: "#" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 The Edge Barber Shop. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}