"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="text-stagger"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="medium"
            sizing="mediumLargeSizeMediumTitles"
            background="floatingGradient"
            cardStyle="soft-shadow"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="solid"
            headingFontWeight="light"
        >
            <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":"Testimonial","id":"testimonials-section"},
                            {"name":"Pricing","id":"pricing-section"},
                            {"name":"Contact","id":"contact-section"}
                        ]}
                        button={{"text":"Book Now","href":"#contact-section"}}
                        brandName="Elegant Retreat"
                    />
                </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 Articles"
                            description="Discover our latest insights and updates from the Elegant Retreat"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                            tagAnimation="slide-up"
                            buttonAnimation="slide-up"
                        />
                    </div>
                )}
            </ReactLenis>
        </ThemeProvider>
    );
}