"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
import FooterMedia from '@/components/sections/footer/FooterMedia';
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-magnetic"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="medium"
            sizing="largeSmall"
            background="circleGradient"
            cardStyle="gradient-radial"
            primaryButtonStyle="flat"
            secondaryButtonStyle="layered"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Dashboard"
                        navItems={[
                            {"name":"Home","id":"/"},
                            {"name":"Overview","id":"overview"},
                            {"name":"Analytics","id":"analytics"},
                            {"name":"Reports","id":"reports"},
                            {"name":"Settings","id":"settings"},
                            {"name":"Help","id":"help"}
                        ]}
                        button={{"text":"Export Data","href":"#"}}
                    />
                </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="Dashboard Insights"
                            description="Explore the latest data analytics trends and dashboard best practices"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-vector/dashboard-user-panel-template_52683-29391.jpg"
                        imageAlt="Dashboard footer"
                        logoText="Dashboard Pro"
                        copyrightText="© 2025 Dashboard Pro. All rights reserved."
                        columns={[
                            {"title":"Product","items":[{"label":"Features","href":"#"},{"label":"Pricing","href":"#"},{"label":"Security","href":"#"}]},
                            {"title":"Company","items":[{"label":"About","href":"#"},{"label":"Blog","href":"#"},{"label":"Careers","href":"#"}]},
                            {"title":"Resources","items":[{"label":"Documentation","href":"#"},{"label":"Support","href":"#"},{"label":"Contact","href":"#"}]}
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}