"use client";

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 { useProductCatalog } from "@/hooks/useProductCatalog";
import FooterCard from '@/components/sections/footer/FooterCard';
import { Twitter, Instagram, Facebook } from 'lucide-react';

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

    if (isLoading) {
        return (
            <ThemeProvider
                defaultButtonVariant="shift-hover"
                defaultTextAnimation="background-highlight"
                borderRadius="rounded"
                contentWidth="mediumLarge"
                sizing="largeSmall"
                background="blurBottom"
                cardStyle="elevated"
                primaryButtonStyle="shadow"
                secondaryButtonStyle="layered"
                headingFontWeight="medium"
            >
                <ReactLenis root>
                    <div id="navbar" data-section="navbar">
                        <NavbarStyleFullscreen
                            brandName="San Francisco"
                            navItems={[
                                {"name":"Home","id":"/"},
                                {"name":"About","id":"about"},
                                {"name":"Attractions","id":"attractions"},
                                {"name":"Neighborhoods","id":"neighborhoods"},
                                {"name":"Blog","id":"blog"},
                                {"name":"Contact","id":"contact"},
                                {"name":"Shop","id":"/shop"}
                            ]}
                            bottomLeftText="Explore the Bay"
                            bottomRightText="hello@sf-guide.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="San Francisco Guide"
                            copyrightText="© 2025 San Francisco Travel Guide. All rights reserved. Exploring the magic of SF."
                            socialLinks={[
                                {"icon":Twitter,"href":"https://twitter.com/sfguide","ariaLabel":"Twitter"},
                                {"icon":Instagram,"href":"https://instagram.com/sfguide","ariaLabel":"Instagram"},
                                {"icon":Facebook,"href":"https://facebook.com/sfguide","ariaLabel":"Facebook"}
                            ]}
                        />
                    </div>
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="mediumLarge"
            sizing="largeSmall"
            background="blurBottom"
            cardStyle="elevated"
            primaryButtonStyle="shadow"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="navbar" data-section="navbar">
                    <NavbarStyleFullscreen
                        brandName="San Francisco"
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"About","id":"about"},
                            {"name":"Attractions","id":"attractions"},
                            {"name":"Neighborhoods","id":"neighborhoods"},
                            {"name":"Blog","id":"blog"},
                            {"name":"Contact","id":"contact"},
                            {"name":"Shop","id":"/shop"}
                        ]}
                        bottomLeftText="Explore the Bay"
                        bottomRightText="hello@sf-guide.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="San Francisco Guide"
                        copyrightText="© 2025 San Francisco Travel Guide. All rights reserved. Exploring the magic of SF."
                        socialLinks={[
                            {"icon":Twitter,"href":"https://twitter.com/sfguide","ariaLabel":"Twitter"},
                            {"icon":Instagram,"href":"https://instagram.com/sfguide","ariaLabel":"Instagram"},
                            {"icon":Facebook,"href":"https://facebook.com/sfguide","ariaLabel":"Facebook"}
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}