"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import FooterCard from '@/components/sections/footer/FooterCard';
import { Facebook, Twitter, Instagram, Youtube } 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="elastic-effect"
                defaultTextAnimation="entrance-slide"
                borderRadius="soft"
                contentWidth="mediumSmall"
                sizing="mediumLargeSizeLargeTitles"
                background="floatingGradient"
                cardStyle="elevated"
                primaryButtonStyle="flat"
                secondaryButtonStyle="layered"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleApple
                            brandName="Family Lovers"
                            navItems={[
                                {"name":"Home","id":"/"},
                                {"name":"Team","id":"/team"},
                                {"name":"Players","id":"/players"},
                                {"name":"About","id":"/about"},
                                {"name":"Contact","id":"/contact"},
                                {"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">
                        <FooterCard
                            logoText="Family Lovers"
                            copyrightText="© 2025 Alabama Basketball Family Lovers. All rights reserved."
                            socialLinks={[
                                {"icon":Facebook,"href":"https://facebook.com/alabamabasketball","ariaLabel":"Facebook"},
                                {"icon":Twitter,"href":"https://twitter.com/alabamahoops","ariaLabel":"Twitter"},
                                {"icon":Instagram,"href":"https://instagram.com/alabamahoops","ariaLabel":"Instagram"},
                                {"icon":Youtube,"href":"https://youtube.com/alabamabasketball","ariaLabel":"YouTube"}
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="mediumLargeSizeLargeTitles"
            background="floatingGradient"
            cardStyle="elevated"
            primaryButtonStyle="flat"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleApple
                        brandName="Family Lovers"
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"Team","id":"/team"},
                            {"name":"Players","id":"/players"},
                            {"name":"About","id":"/about"},
                            {"name":"Contact","id":"/contact"},
                            {"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">
                    <FooterCard
                        logoText="Family Lovers"
                        copyrightText="© 2025 Alabama Basketball Family Lovers. All rights reserved."
                        socialLinks={[
                            {"icon":Facebook,"href":"https://facebook.com/alabamabasketball","ariaLabel":"Facebook"},
                            {"icon":Twitter,"href":"https://twitter.com/alabamahoops","ariaLabel":"Twitter"},
                            {"icon":Instagram,"href":"https://instagram.com/alabamahoops","ariaLabel":"Instagram"},
                            {"icon":Youtube,"href":"https://youtube.com/alabamabasketball","ariaLabel":"YouTube"}
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}