"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-stagger"
                defaultTextAnimation="background-highlight"
                borderRadius="soft"
                contentWidth="compact"
                sizing="largeSmallSizeMediumTitles"
                background="none"
                cardStyle="subtle-shadow"
                primaryButtonStyle="gradient"
                secondaryButtonStyle="solid"
                headingFontWeight="bold"
            >
                <ReactLenis root>
                    <NavbarStyleCentered
                        brandName="Inia"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "/shop" }
                        ]}
                        button={{ text: "Reserve Table", href: "contact" }}
                    />
                    <main className="min-h-screen flex items-center justify-center pt-20">
                        <p className="text-foreground">Loading products...</p>
                    </main>
                    <FooterMedia
                        imageSrc="asset://footer-coffee-beans"
                        imageAlt="Premium coffee beans"
                        logoText="Inia Coffee Shop"
                        copyrightText="© 2025 Inia Coffee Shop. All rights reserved."
                        columns={[
                            {
                                title: "Menu",                                items: [
                                    { label: "Espresso Drinks", href: "#" },
                                    { label: "Cold Beverages", href: "#" },
                                    { label: "Pastries & Snacks", href: "#" },
                                    { label: "Limited Editions", href: "#" }
                                ]
                            },
                            {
                                title: "Visit Us",                                items: [
                                    { label: "Hours", href: "#" },
                                    { label: "Location", href: "#" },
                                    { label: "Reservations", href: "#" },
                                    { label: "Contact", href: "#" }
                                ]
                            },
                            {
                                title: "More",                                items: [
                                    { label: "About Inia", href: "#" },
                                    { label: "Our Story", href: "#" },
                                    { label: "Sustainability", href: "#" },
                                    { label: "Press Kit", href: "#" }
                                ]
                            }
                        ]}
                    />
                </ReactLenis>
            </ThemeProvider>
        );
    }

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="compact"
            sizing="largeSmallSizeMediumTitles"
            background="none"
            cardStyle="subtle-shadow"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="solid"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <NavbarStyleCentered
                    brandName="Inia"
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Shop", id: "/shop" }
                    ]}
                    button={{ text: "Reserve Table", href: "contact" }}
                />
                <ProductCatalog
                    layout="page"
                    products={products}
                    searchValue={search}
                    onSearchChange={setSearch}
                    searchPlaceholder="Search products..."
                    filters={filters}
                    emptyMessage="No products found"
                />
                <FooterMedia
                    imageSrc="asset://footer-coffee-beans"
                    imageAlt="Premium coffee beans"
                    logoText="Inia Coffee Shop"
                    copyrightText="© 2025 Inia Coffee Shop. All rights reserved."
                    columns={[
                        {
                            title: "Menu",                            items: [
                                { label: "Espresso Drinks", href: "#" },
                                { label: "Cold Beverages", href: "#" },
                                { label: "Pastries & Snacks", href: "#" },
                                { label: "Limited Editions", href: "#" }
                            ]
                        },
                        {
                            title: "Visit Us",                            items: [
                                { label: "Hours", href: "#" },
                                { label: "Location", href: "#" },
                                { label: "Reservations", href: "#" },
                                { label: "Contact", href: "#" }
                            ]
                        },
                        {
                            title: "More",                            items: [
                                { label: "About Inia", href: "#" },
                                { label: "Our Story", href: "#" },
                                { label: "Sustainability", href: "#" },
                                { label: "Press Kit", href: "#" }
                            ]
                        }
                    ]}
                />
            </ReactLenis>
        </ThemeProvider>
    );
}