"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered';
import FooterMedia from '@/components/sections/footer/FooterMedia';
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="soft"
                contentWidth="mediumSmall"
                sizing="largeSmall"
                background="fluid"
                cardStyle="gradient-mesh"
                primaryButtonStyle="radial-glow"
                secondaryButtonStyle="solid"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleCentered
                            brandName="NovaWeb"
                            navItems={[
                                { name: "Home", id: "/" },
                                { name: "About", id: "about" },
                                { name: "Services", id: "services" },
                                { name: "Portfolio", id: "portfolio" },
                                { name: "Team", id: "team" },
                                { 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">
                        <FooterMedia
                            imageSrc="https://img.b2bpic.net/free-vector/blue-background-cone-shaped_1017-4109.jpg"
                            imageAlt="NovaWeb creative workspace"
                            logoText="NovaWeb"
                            copyrightText="© 2025 NovaWeb. All rights reserved."
                            columns={[
                                {
                                    title: "Services",                                    items: [
                                        { label: "Website Design", href: "#services" },
                                        { label: "Website Redesign", href: "#services" },
                                        { label: "Brand Integration", href: "#services" },
                                        { label: "Optimization", href: "#services" }
                                    ]
                                },
                                {
                                    title: "Company",                                    items: [
                                        { label: "About Us", href: "#about" },
                                        { label: "Our Work", href: "#portfolio" },
                                        { label: "Team", href: "#team" },
                                        { label: "Contact", href: "#contact" }
                                    ]
                                },
                                {
                                    title: "Resources",                                    items: [
                                        { label: "Blog", href: "#" },
                                        { label: "Case Studies", href: "#portfolio" },
                                        { label: "Privacy Policy", href: "#" },
                                        { label: "Terms of Service", href: "#" }
                                    ]
                                }
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-shift"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="largeSmall"
            background="fluid"
            cardStyle="gradient-mesh"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleCentered
                        brandName="NovaWeb"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Services", id: "services" },
                            { name: "Portfolio", id: "portfolio" },
                            { name: "Team", id: "team" },
                            { 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">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-vector/blue-background-cone-shaped_1017-4109.jpg"
                        imageAlt="NovaWeb creative workspace"
                        logoText="NovaWeb"
                        copyrightText="© 2025 NovaWeb. All rights reserved."
                        columns={[
                            {
                                title: "Services",                                items: [
                                    { label: "Website Design", href: "#services" },
                                    { label: "Website Redesign", href: "#services" },
                                    { label: "Brand Integration", href: "#services" },
                                    { label: "Optimization", href: "#services" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Our Work", href: "#portfolio" },
                                    { label: "Team", href: "#team" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                title: "Resources",                                items: [
                                    { label: "Blog", href: "#" },
                                    { label: "Case Studies", href: "#portfolio" },
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}