"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen';
import FooterSimple from '@/components/sections/footer/FooterSimple';
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="shift-hover"
                defaultTextAnimation="reveal-blur"
                borderRadius="sharp"
                contentWidth="medium"
                sizing="largeSmall"
                background="aurora"
                cardStyle="elevated"
                primaryButtonStyle="gradient"
                secondaryButtonStyle="layered"
                headingFontWeight="normal"
            >
                <ReactLenis root>
                    <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Team", id: "team" },
                            { name: "Achievements", id: "achievements" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        brandName="Goleodor"
                        bottomLeftText="Soccer Excellence Since 2018"
                        bottomRightText="join@goleodor.com"
                    />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <FooterSimple
                        columns={[
                            {
                                title: "Navigate",                                items: [
                                    { label: "Home", href: "/" },
                                    { label: "About", href: "#about" },
                                    { label: "Team", href: "#team" }
                                ]
                            },
                            {
                                title: "Programs",                                items: [
                                    { label: "Youth Academy", href: "#" },
                                    { label: "Competitive Teams", href: "#" },
                                    { label: "Training", href: "#" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact", href: "/contacts" },
                                    { label: "Email", href: "mailto:join@goleodor.com" },
                                    { label: "Follow Us", href: "#" }
                                ]
                            }
                        ]}
                        bottomLeftText="© 2025 Goleodor FC. All rights reserved."
                        bottomRightText="Developing Champions Since 2018"
                    />
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="reveal-blur"
            borderRadius="sharp"
            contentWidth="medium"
            sizing="largeSmall"
            background="aurora"
            cardStyle="elevated"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                <NavbarStyleFullscreen
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "About", id: "about" },
                        { name: "Team", id: "team" },
                        { name: "Achievements", id: "achievements" },
                        { name: "Contact", id: "contact" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    brandName="Goleodor"
                    bottomLeftText="Soccer Excellence Since 2018"
                    bottomRightText="join@goleodor.com"
                />
                </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>
                <FooterSimple
                    columns={[
                        {
                            title: "Navigate",                            items: [
                                { label: "Home", href: "/" },
                                { label: "About", href: "#about" },
                                { label: "Team", href: "#team" }
                            ]
                        },
                        {
                            title: "Programs",                            items: [
                                { label: "Youth Academy", href: "#" },
                                { label: "Competitive Teams", href: "#" },
                                { label: "Training", href: "#" }
                            ]
                        },
                        {
                            title: "Connect",                            items: [
                                { label: "Contact", href: "/contacts" },
                                { label: "Email", href: "mailto:join@goleodor.com" },
                                { label: "Follow Us", href: "#" }
                            ]
                        }
                    ]}
                    bottomLeftText="© 2025 Goleodor FC. All rights reserved."
                    bottomRightText="Developing Champions Since 2018"
                />
            </ReactLenis>
        </ThemeProvider>
    );
}