"use client";

import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen';
import FooterLogoEmphasis from '@/components/sections/footer/FooterLogoEmphasis';
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="background-highlight"
                borderRadius="soft"
                contentWidth="small"
                sizing="largeSmall"
                background="noiseDiagonalGradient"
                cardStyle="inset"
                primaryButtonStyle="double-inset"
                secondaryButtonStyle="solid"
                headingFontWeight="bold"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="Pawsitive Haven"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Adopt", id: "featured-pets" },
                            { name: "About Us", id: "about" },
                            { name: "Get Involved", id: "how-to-help" },
                            { name: "Contact", id: "contact" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        bottomLeftText="Saving Lives, One Paw at a Time"
                        bottomRightText="info@pawsitivehaven.org"
                        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">
                    <FooterLogoEmphasis
                        logoText="Pawsitive Haven"
                        columns={[
                            {
                                items: [
                                    { label: "Home", href: "#home" },
                                    { label: "Featured Pets", href: "#featured-pets" },
                                    { label: "About Us", href: "#about" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Get Involved", href: "#how-to-help" },
                                    { label: "Donate", href: "https://example.com/donate" },
                                    { label: "Volunteer", href: "https://example.com/volunteer" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Contact", href: "mailto:info@pawsitivehaven.org" },
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms of Service", href: "#" }
                                ]
                            }
                        ]}
                    />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="small"
            sizing="largeSmall"
            background="noiseDiagonalGradient"
            cardStyle="inset"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="solid"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                <NavbarStyleFullscreen
                    brandName="Pawsitive Haven"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Adopt", id: "featured-pets" },
                        { name: "About Us", id: "about" },
                        { name: "Get Involved", id: "how-to-help" },
                        { name: "Contact", id: "contact" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    bottomLeftText="Saving Lives, One Paw at a Time"
                    bottomRightText="info@pawsitivehaven.org"
                    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">
                <FooterLogoEmphasis
                    logoText="Pawsitive Haven"
                    columns={[
                        {
                            items: [
                                { label: "Home", href: "#home" },
                                { label: "Featured Pets", href: "#featured-pets" },
                                { label: "About Us", href: "#about" }
                            ]
                        },
                        {
                            items: [
                                { label: "Get Involved", href: "#how-to-help" },
                                { label: "Donate", href: "https://example.com/donate" },
                                { label: "Volunteer", href: "https://example.com/volunteer" }
                            ]
                        },
                        {
                            items: [
                                { label: "Contact", href: "mailto:info@pawsitivehaven.org" },
                                { label: "Privacy Policy", href: "#" },
                                { label: "Terms of Service", href: "#" }
                            ]
                        }
                    ]}
                />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}