"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
import FooterBase from "@/components/sections/footer/FooterBase";
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import { useBlogPosts } from "@/hooks/useBlogPosts";

export default function BlogPage() {
    const { posts, isLoading } = useBlogPosts();

    return (
        <ThemeProvider
            defaultButtonVariant="expand-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="rounded"
            contentWidth="medium"
            sizing="largeSmallSizeMediumTitles"
            background="circleGradient"
            cardStyle="gradient-radial"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        brandName="ShopHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "products" },
                            { name: "About", id: "about" },
                            { name: "Reviews", id: "reviews" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "View Cart", onClick: function() { console.log('View cart'); } }}
                    />
                </div>

                {isLoading ? (
                    <div className="w-content-width mx-auto py-20 text-center">
                        <p className="text-foreground">Loading posts...</p>
                    </div>
                ) : (
                    <div id="blog" data-section="blog">
                        <BlogCardOne
                            blogs={posts}
                            title="Latest Articles"
                            description="Discover insights, tips, and updates from ShopHub"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                            tag="Blog"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBase
                        logoText="ShopHub"
                        copyrightText="© 2025 ShopHub. All rights reserved."
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "Products", href: "products" },
                                    { label: "New Arrivals", href: "products" },
                                    { label: "Best Sellers", href: "products" },
                                    { label: "Sale", href: "products" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "about" },
                                    { label: "Blog", href: "https://blog.shophub.com" },
                                    { label: "Careers", href: "https://careers.shophub.com" },
                                    { label: "Press", href: "https://press.shophub.com" }
                                ]
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "Help Center", href: "https://help.shophub.com" },
                                    { label: "Contact Us", href: "contact" },
                                    { label: "Shipping Info", href: "https://shipping.shophub.com" },
                                    { label: "Returns", href: "https://returns.shophub.com" }
                                ]
                            }
                        ]}
                        onPrivacyClick={function() { window.location.href = '/privacy'; }}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}