"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="hover-bubble"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="medium"
            sizing="large"
            background="blurBottom"
            cardStyle="inset"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        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: "Faq", id: "faq-section" },
                            { name: "Contact", id: "contact-section" }
                        ]}
                        brandName="24/7 Emergency Plumber"
                        button={{ text: "Get Free Quote", href: "#contact-section" }}
                    />
                </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="Latest Plumbing Insights"
                            description="Expert tips and industry news from our professional plumbing team"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                            ariaLabel="Blog section"
                        />
                    </div>
                )}
            </ReactLenis>
        </ThemeProvider>
    );
}