"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="largeSmallSizeMediumTitles"
            background="noiseDiagonalGradient"
            cardStyle="gradient-bordered"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="radial-glow"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Features", id: "/#features" },
                            { name: "Products", id: "/#products" },
                            { name: "Testimonials", id: "/#testimonials" },
                            { name: "Contact", id: "/#contact" }
                        ]}
                        brandName="NoteGenius AI"
                        button={{ text: "Get Started", href: "/#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">
                            <BlogCardOne
                                blogs={posts.map(post => ({...post, onBlogClick: () => {}}))}
                                title="Latest Articles"
                                description="Insights and updates from our team"
                                animationType="slide-up"
                                textboxLayout="default"
                                useInvertedBackground={false}
                                carouselMode="buttons"
                            />
                        </div>
                    )}

                    <div id="footer" data-section="footer">
                        <FooterMedia
                           imageSrc="https://webuild-dev.s3.eu-north-1.amazonaws.com/users/user_32SzEkxKoNyIbQ4hnQYui6BHsfB/a-clean-modern-ai-notetaking-dashboard-i-1771701006792-1be35ae6.png?_wi=4"
                           imageAlt="NoteGenius AI Dashboard Footer"
                           columns={[
                               { title: "Product", items: [{ label: "Features", href: "/#features" }] },
                               { title: "Company", items: [] },
                               { title: "Resources", items: [{ label: "Blog", href: "/blog" }, { label: "Support", href: "/#faq" }] }
                           ]}
                           logoText="NoteGenius AI"
                           copyrightText="© 2024 NoteGenius AI. All rights reserved."
                        />
                    </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
