"use client";

import { useState } from "react";
import ReactLenis from "lenis/react";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleFullscreen from '@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen';
import ProductCatalog from "@/components/ecommerce/productCatalog/ProductCatalog";
import FooterCard from '@/components/sections/footer/FooterCard';
import { useProductCatalog } from "@/hooks/useProductCatalog";
import { Twitter, Instagram, Linkedin, Mail } from "lucide-react";

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

    const [cartOpen, setCartOpen] = useState(false);

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="hover-bubble"
                defaultTextAnimation="background-highlight"
                borderRadius="rounded"
                contentWidth="medium"
                sizing="mediumSizeLargeTitles"
                background="floatingGradient"
                cardStyle="gradient-radial"
                primaryButtonStyle="shadow"
                secondaryButtonStyle="glass"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleFullscreen
                            navItems={[
                                {"name":"Home","id":"/"},
                                {"name":"Shop","id":"/shop"}
                            ]}
                            brandName="SocialHub"
                            bottomLeftText="Social Community"
                            bottomRightText="hello@socialhub.com"
                        />
                    </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">
                        <FooterCard
                            logoText="SocialHub"
                            copyrightText="© 2025 SocialHub. All rights reserved."
                            socialLinks={[
                                {"icon":Twitter,"href":"https://twitter.com","ariaLabel":"Twitter"},
                                {"icon":Instagram,"href":"https://instagram.com","ariaLabel":"Instagram"},
                                {"icon":Linkedin,"href":"https://linkedin.com","ariaLabel":"LinkedIn"},
                                {"icon":Mail,"href":"mailto:hello@socialhub.com","ariaLabel":"Email"}
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="hover-bubble"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="medium"
            sizing="mediumSizeLargeTitles"
            background="floatingGradient"
            cardStyle="gradient-radial"
            primaryButtonStyle="shadow"
            secondaryButtonStyle="glass"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"Shop","id":"/shop"}
                        ]}
                        brandName="SocialHub"
                        bottomLeftText="Social Community"
                        bottomRightText="hello@socialhub.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>
                <div id="footer" data-section="footer">
                    <FooterCard
                        logoText="SocialHub"
                        copyrightText="© 2025 SocialHub. All rights reserved."
                        socialLinks={[
                            {"icon":Twitter,"href":"https://twitter.com","ariaLabel":"Twitter"},
                            {"icon":Instagram,"href":"https://instagram.com","ariaLabel":"Instagram"},
                            {"icon":Linkedin,"href":"https://linkedin.com","ariaLabel":"LinkedIn"},
                            {"icon":Mail,"href":"mailto:hello@socialhub.com","ariaLabel":"Email"}
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}