"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 FooterMedia from '@/components/sections/footer/FooterMedia';
import { useProductCatalog } from "@/hooks/useProductCatalog";

export default function ShopPage() {
    const {
        products,
        isLoading,
        search,
        setSearch,
        filters,
    } = useProductCatalog({ basePath: "/shop" });

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="expand-hover"
                defaultTextAnimation="background-highlight"
                borderRadius="rounded"
                contentWidth="mediumSmall"
                sizing="largeSmallSizeLargeTitles"
                background="floatingGradient"
                cardStyle="gradient-bordered"
                primaryButtonStyle="primary-glow"
                secondaryButtonStyle="glass"
                headingFontWeight="semibold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleCentered
                            brandName="SocialHub"
                            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">
                        <FooterMedia
                            imageSrc="https://img.b2bpic.net/free-photo/close-up-portrait-curly-handsome-european-male_176532-8133.jpg"
                            imageAlt="Profile footer image"
                            columns={[
                                {
                                    title: "Profile",                                    items: [
                                        { label: "About", href: "#profile" },
                                        { label: "Posts", href: "#feed" },
                                        { label: "Stories", href: "#stories" },
                                        { label: "Saved", href: "#" }
                                    ]
                                },
                                {
                                    title: "Social",                                    items: [
                                        { label: "Instagram", href: "#" },
                                        { label: "Twitter", href: "#" },
                                        { label: "LinkedIn", href: "#" },
                                        { label: "Pinterest", href: "#" }
                                    ]
                                },
                                {
                                    title: "Resources",                                    items: [
                                        { label: "Blog", href: "#" },
                                        { label: "Portfolio", href: "#" },
                                        { label: "Contact", href: "#contact" },
                                        { label: "FAQ", href: "#" }
                                    ]
                                }
                            ]}
                            logoText="SocialHub"
                            copyrightText="© 2025 SocialHub. All rights reserved."
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="expand-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="mediumSmall"
            sizing="largeSmallSizeLargeTitles"
            background="floatingGradient"
            cardStyle="gradient-bordered"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleCentered
                        brandName="SocialHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { 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">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/close-up-portrait-curly-handsome-european-male_176532-8133.jpg"
                        imageAlt="Profile footer image"
                        columns={[
                            {
                                title: "Profile",                                items: [
                                    { label: "About", href: "#profile" },
                                    { label: "Posts", href: "#feed" },
                                    { label: "Stories", href: "#stories" },
                                    { label: "Saved", href: "#" }
                                ]
                            },
                            {
                                title: "Social",                                items: [
                                    { label: "Instagram", href: "#" },
                                    { label: "Twitter", href: "#" },
                                    { label: "LinkedIn", href: "#" },
                                    { label: "Pinterest", href: "#" }
                                ]
                            },
                            {
                                title: "Resources",                                items: [
                                    { label: "Blog", href: "#" },
                                    { label: "Portfolio", href: "#" },
                                    { label: "Contact", href: "#contact" },
                                    { label: "FAQ", href: "#" }
                                ]
                            }
                        ]}
                        logoText="SocialHub"
                        copyrightText="© 2025 SocialHub. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}