"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="icon-arrow"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="smallMedium"
            sizing="large"
            background="circleGradient"
            cardStyle="subtle-shadow"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="extrabold"
        >
            <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":"Product","id":"products-section"},
                            {"name":"Testimonial","id":"testimonials-section"},
                            {"name":"Faq","id":"faq-section"},
                            {"name":"Contact","id":"contact-section"}
                        ]}
                        brandName="CozyBeans Coffee"
                        bottomLeftText="Global Community"
                        bottomRightText="hello@cozybeans.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">
                        <BlogCardThree
                            blogs={posts}
                            title="CozyBeans Coffee Stories"
                            description="Discover the art of coffee through our featured articles and brewing guides"
                            tag="Coffee Blog"
                            tagIcon={BookOpen}
                            tagAnimation="slide-up"
                            buttons={[
                                {text: "View All Posts", href: "/blog/all"},
                                {text: "Subscribe", onClick: () => console.log("Subscribe clicked")}
                            ]}
                            buttonAnimation="slide-up"
                            textboxLayout="split-actions"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            uniformGridCustomHeightClasses="min-h-[650px]"
                        />
                    </div>
                )}

            </ReactLenis>
        </ThemeProvider>
    );
}