"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
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="bounce-effect"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="medium"
            sizing="largeSizeMediumTitles"
            background="noiseDiagonalGradient"
            cardStyle="inset"
            primaryButtonStyle="diagonal-gradient"
            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":"Product","id":"product-section"},
                            {"name":"Testimonial","id":"testimonial-section"},
                            {"name":"Contact","id":"contact-section"}
                        ]}
                        button={{"text":"Order Now","href":"#product-section"}}
                        brandName="Ukrainian Bakery"
                    />
                </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="Fresh From Our Bakery Blog"
                            description="Discover the latest recipes, baking tips, and stories from our Ukrainian kitchen"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                        />
                    </div>
                )}
            </ReactLenis>
        </ThemeProvider>
    );
}