"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="small"
            sizing="large"
            background="circleGradient"
            cardStyle="solid"
            primaryButtonStyle="flat"
            secondaryButtonStyle="layered"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="Y&B Roofing Inc."
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Services", id: "services" },
                            { name: "About", id: "about" },
                            { name: "Why Y&B", id: "why-yb" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "Contact", id: "contact" }
                        ]}
                    />
                </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="Roofing Insights & Updates"
                            description="Expert advice, industry trends, and project highlights from Y&B Roofing professionals"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoReveal
                        logoText="Y&B Roofing Inc."
                        leftLink={{
                            text: "Privacy Policy",                            href: "#"
                        }}
                        rightLink={{
                            text: "Terms of Service",                            href: "#"
                        }}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}