"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterLogoEmphasis from '@/components/sections/footer/FooterLogoEmphasis';
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-bubble"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="compact"
            sizing="largeSizeMediumTitles"
            background="none"
            cardStyle="outline"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="glass"
            headingFontWeight="extrabold"
        >
            <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: "Login", 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">
                        <BlogCardTwo
                            blogs={posts}
                            title="Latest Articles"
                            description="Stay updated with our latest insights and updates from our team"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        logoText="Dashboard"
                        columns={[
                            {
                                items: [
                                    { label: "Overview", href: "overview" },
                                    { label: "Analytics", href: "analytics" },
                                    { label: "Reports", href: "reports" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Settings", href: "settings" },
                                    { label: "Team Management", href: "#team" },
                                    { label: "API Docs", href: "#api" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Help Center", href: "help" },
                                    { label: "Contact Support", href: "#support" },
                                    { label: "Status Page", href: "#status" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}