"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from '@/components/sections/blog/BlogCardOne';
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="hover-magnetic"
            defaultTextAnimation="background-highlight"
            borderRadius="rounded"
            contentWidth="medium"
            sizing="largeSmallSizeMediumTitles"
            background="circleGradient"
            cardStyle="gradient-mesh"
            primaryButtonStyle="flat"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="normal"
        >
            <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":"Metric","id":"metrics-section"},
                            {"name":"Testimonial","id":"testimonials-section"},
                            {"name":"Contact","id":"contact-section"}
                        ]}
                        button={{"text":"Get Quote","href":"#contact-section"}}
                        brandName="AquaBuild Pool Services"
                    />
                </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 Pool & Construction Insights"
                            description="Discover expert tips, industry insights, and project showcases from AquaBuild's experienced team"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}
            </ReactLenis>
        </ThemeProvider>
    );
}