"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import FooterCard from '@/components/sections/footer/FooterCard';
import { Facebook, Phone, Mail } from 'lucide-react';
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-stagger"
                defaultTextAnimation="background-highlight"
                borderRadius="soft"
                contentWidth="smallMedium"
                sizing="mediumLarge"
                background="circleGradient"
                cardStyle="inset"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="solid"
                headingFontWeight="extrabold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarLayoutFloatingInline
                            brandName="Old Boy Domino"
                            navItems={[
                                {"name":"Home","id":"/"},
                                {"name":"About","id":"about"},
                                {"name":"Features","id":"features"},
                                {"name":"Team","id":"team"},
                                {"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">
                        <FooterCard
                            logoText="Old Boy Domino"
                            copyrightText="© 2025 Old Boy Domino Club. All rights reserved."
                            socialLinks={[
                                {"icon":Facebook,"href":"https://facebook.com/oldboydomino","ariaLabel":"Facebook"},
                                {"icon":Phone,"href":"tel:+1234567890","ariaLabel":"Phone"},
                                {"icon":Mail,"href":"mailto:info@oldboydomino.club","ariaLabel":"Email"}
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="smallMedium"
            sizing="mediumLarge"
            background="circleGradient"
            cardStyle="inset"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarLayoutFloatingInline
                        brandName="Old Boy Domino"
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"About","id":"about"},
                            {"name":"Features","id":"features"},
                            {"name":"Team","id":"team"},
                            {"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">
                    <FooterCard
                        logoText="Old Boy Domino"
                        copyrightText="© 2025 Old Boy Domino Club. All rights reserved."
                        socialLinks={[
                            {"icon":Facebook,"href":"https://facebook.com/oldboydomino","ariaLabel":"Facebook"},
                            {"icon":Phone,"href":"tel:+1234567890","ariaLabel":"Phone"},
                            {"icon":Mail,"href":"mailto:info@oldboydomino.club","ariaLabel":"Email"}
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}