"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="rounded"
            contentWidth="mediumLarge"
            sizing="mediumLargeSizeLargeTitles"
            background="noiseDiagonalGradient"
            cardStyle="layered-gradient"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="glass"
            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: "Faq", id: "faq-section" },
                            { name: "Contact", id: "contact-section" }
                        ]}
                        button={{ text: "Visit Us", href: "#contact-section" }}
                        brandName="Brew & Bean"
                    />
                </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">
                        <BlogCardThree
                            blogs={posts}
                            title="Featured Coffee Stories"
                            description="Discover the art of coffee brewing and the stories behind every cup at Brew & Bean"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Coffee Blog"
                            uniformGridCustomHeightClasses="min-h-[650px]"
                            tagAnimation="slide-up"
                            buttons={[
                                { text: "View All Articles", href: "#blog" },
                                { text: "Subscribe", href: "#contact-section" }
                            ]}
                            buttonAnimation="slide-up"
                        />
                    </div>
                )}
            </ReactLenis>
        </ThemeProvider>
    );
}