"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="icon-arrow"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="smallMedium"
            sizing="medium"
            background="noiseDiagonalGradient"
            cardStyle="soft-shadow"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="extrabold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleCentered
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Hero", id: "hero-section" },
                            { name: "About", id: "about-section" },
                            { name: "Feature", id: "features-section" },
                            { name: "Product", id: "products-section" },
                            { name: "Testimonial", id: "testimonials-section" },
                            { name: "Contact", id: "contact-section" }
                        ]}
                        button={{ text: "Get Quote", href: "#contact-section" }}
                        brandName="San Diego Tires"
                    />
                </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">
                        <BlogCardTwo
                            blogs={posts}
                            title="Latest Tire & Automotive Articles"
                            description="Expert insights on tire maintenance, automotive care, and road safety tips"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Expert Tips"
                        />
                    </div>
                )}
            </ReactLenis>
        </ThemeProvider>
    );
}