"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import FooterBaseCard from '@/components/sections/footer/FooterBaseCard';
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-shift"
                defaultTextAnimation="entrance-slide"
                borderRadius="pill"
                contentWidth="compact"
                sizing="largeSmall"
                background="aurora"
                cardStyle="soft-shadow"
                primaryButtonStyle="diagonal-gradient"
                secondaryButtonStyle="layered"
                headingFontWeight="bold"
            >
                <ReactLenis root>
                    <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="Flamingo"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" }
                        ]}
                    />
                    </div>
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <FooterBaseCard
                        logoText="Flamingo"
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "All Products", href: "/shop" },
                                    { label: "New Arrivals", href: "/shop" },
                                    { label: "Best Sellers", href: "/shop" },
                                    { label: "Collections", href: "/shop" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "/" },
                                    { label: "Our Story", href: "/" },
                                    { label: "Blog", href: "/" },
                                    { label: "Sustainability", href: "/" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Contact Us", href: "/contacts" },
                                    { label: "FAQ", href: "/" },
                                    { label: "Shipping Info", href: "/" },
                                    { label: "Returns", href: "/" }
                                ]
                            },
                            {
                                title: "Follow",                                items: [
                                    { label: "Instagram", href: "/" },
                                    { label: "Facebook", href: "/" },
                                    { label: "Pinterest", href: "/" },
                                    { label: "Twitter", href: "/" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Flamingo Cups. All rights reserved."
                    />
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-shift"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="compact"
            sizing="largeSmall"
            background="aurora"
            cardStyle="soft-shadow"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                <NavbarStyleApple
                    brandName="Flamingo"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Shop", id: "/shop" }
                    ]}
                />
                </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>
                <FooterBaseCard
                    logoText="Flamingo"
                    columns={[
                        {
                            title: "Shop",                            items: [
                                { label: "All Products", href: "/shop" },
                                { label: "New Arrivals", href: "/shop" },
                                { label: "Best Sellers", href: "/shop" },
                                { label: "Collections", href: "/shop" }
                            ]
                        },
                        {
                            title: "Company",                            items: [
                                { label: "About Us", href: "/" },
                                { label: "Our Story", href: "/" },
                                { label: "Blog", href: "/" },
                                { label: "Sustainability", href: "/" }
                            ]
                        },
                        {
                            title: "Support",                            items: [
                                { label: "Contact Us", href: "/contacts" },
                                { label: "FAQ", href: "/" },
                                { label: "Shipping Info", href: "/" },
                                { label: "Returns", href: "/" }
                            ]
                        },
                        {
                            title: "Follow",                            items: [
                                { label: "Instagram", href: "/" },
                                { label: "Facebook", href: "/" },
                                { label: "Pinterest", href: "/" },
                                { label: "Twitter", href: "/" }
                            ]
                        }
                    ]}
                    copyrightText="© 2025 Flamingo Cups. All rights reserved."
                />
            </ReactLenis>
        </ThemeProvider>
    );
}