"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="background-highlight"
            borderRadius="pill"
            contentWidth="medium"
            sizing="mediumLarge"
            background="aurora"
            cardStyle="gradient-bordered"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"Hero","id":"hero-section"},
                            {"name":"About","id":"about-section"},
                            {"name":"Feature","id":"features-section"},
                            {"name":"Metric","id":"metric-section"},
                            {"name":"Testimonial","id":"testimonials-section"},
                            {"name":"Contact","id":"contact-section"},
                            {"name":"Footer","id":"footer-section"}
                        ]}
                        brandName="Professional Tennis Player"
                        bottomLeftText="Global Community"
                        bottomRightText="hello@example.com"
                        topBarClassName=""
                    />
                </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 Tennis Insights"
                            description="Stay updated with professional tennis tips, strategies, and tournament analysis from our expert perspective"
                            tag="Tennis Blog"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tagAnimation="opacity"
                            buttonAnimation="opacity"
                            ariaLabel="Tennis blog section"
                        />
                    </div>
                )}
            </ReactLenis>
        </ThemeProvider>
    );
}