"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 NavbarStyleFullscreen from "@/components/navbar/NavbarStyleFullscreen/NavbarStyleFullscreen";
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="directional-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="pill"
            contentWidth="medium"
            sizing="mediumLargeSizeLargeTitles"
            background="none"
            cardStyle="outline"
            primaryButtonStyle="radial-glow"
            secondaryButtonStyle="solid"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleFullscreen
                        brandName="WriteHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Articles", id: "articles" },
                            { name: "Categories", id: "categories" },
                            { name: "About", id: "about" },
                            { name: "Contact", id: "contact" }
                        ]}
                        bottomLeftText="Blog Community"
                        bottomRightText="hello@writehub.com"
                    />
                </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 Articles"
                            description="Discover insights, tutorials, and industry updates from our community of writers"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            carouselMode="buttons"
                            animationType="slide-up"
                            tag="Blog"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/still-life-office-desk-mess_23-2150164813.jpg"
                        imageAlt="Footer background workspace"
                        logoText="WriteHub"
                        copyrightText="© 2025 WriteHub. All rights reserved."
                        columns={[
                            {
                                title: "Content",                                items: [
                                    { label: "All Articles", href: "#articles" },
                                    { label: "Categories", href: "#categories" },
                                    { label: "Most Popular", href: "#popular" },
                                    { label: "Archives", href: "#archives" }
                                ]
                            },
                            {
                                title: "Resources",                                items: [
                                    { label: "Writing Guide", href: "#guide" },
                                    { label: "Best Practices", href: "#practices" },
                                    { label: "Tools & Resources", href: "#tools" },
                                    { label: "Community", href: "#community" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Contact", href: "#contact" },
                                    { label: "Twitter", href: "https://twitter.com" },
                                    { label: "LinkedIn", href: "https://linkedin.com" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}