"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
import FooterLogoEmphasis from "@/components/sections/footer/FooterLogoEmphasis";
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="icon-arrow"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="compact"
            sizing="largeSmallSizeMediumTitles"
            background="aurora"
            cardStyle="soft-shadow"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleCentered
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Dashboard", id: "dashboard" },
                            { name: "Analytics", id: "analytics" },
                            { name: "Reports", id: "reports" },
                            { name: "Settings", id: "settings" },
                            { name: "Help", id: "help" }
                        ]}
                        button={{ text: "Get Started", href: "contact" }}
                        brandName="Dashboard"
                    />
                </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="Latest Dashboard Insights"
                            description="Stay updated with our latest insights and updates from the dashboard team"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                            tag="Blog"
                            buttons={[
                                { text: "View All Posts", href: "/blog" },
                                { text: "Subscribe", href: "/subscribe" }
                            ]}
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterLogoEmphasis
                        logoText="Dashboard"
                        columns={[
                            {
                                items: [
                                    { label: "Dashboard", href: "dashboard" },
                                    { label: "Analytics", href: "analytics" },
                                    { label: "Reports", href: "reports" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Settings", href: "settings" },
                                    { label: "Preferences", href: "preferences" },
                                    { label: "Profile", href: "profile" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Documentation", href: "docs" },
                                    { label: "API Reference", href: "api" },
                                    { label: "Support", href: "support" }
                                ]
                            },
                            {
                                items: [
                                    { label: "Privacy Policy", href: "privacy" },
                                    { label: "Terms of Service", href: "terms" },
                                    { label: "Contact", href: "contact" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}