"use client";

import ReactLenis from "lenis/react";
import BlogCardTwo from '@/components/sections/blog/BlogCardTwo';
import FooterBase from '@/components/sections/footer/FooterBase';
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="directional-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="sharp"
            contentWidth="mediumLarge"
            sizing="large"
            background="none"
            cardStyle="subtle-shadow"
            primaryButtonStyle="diagonal-gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleCentered
                        brandName="SocialHub"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Profile", id: "profile" },
                            { name: "Explore", id: "explore" },
                            { name: "Messages", id: "messages" },
                            { name: "Settings", id: "settings" },
                            { name: "Help", id: "help" }
                        ]}
                        button={{ text: "Sign Out", 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">
                        <BlogCardTwo
                            blogs={posts}
                            title="Community Insights"
                            description="Discover stories, tips, and experiences shared by our vibrant community"
                            tag="Blog"
                            textboxLayout="default"
                            useInvertedBackground="noInvert"
                            animationType="slide-up"
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBase
                        logoText="SocialHub"
                        copyrightText="© 2025 SocialHub. All rights reserved."
                        columns={[
                            {
                                title: "Platform",                                items: [
                                    { label: "Explore", href: "explore" },
                                    { label: "Discover", href: "discover" },
                                    { label: "Trends", href: "trends" }
                                ]
                            },
                            {
                                title: "Community",                                items: [
                                    { label: "Guidelines", href: "guidelines" },
                                    { label: "Safety", href: "safety" },
                                    { label: "Support", href: "support" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact", href: "contact" },
                                    { label: "Business", href: "business" },
                                    { label: "Partnerships", href: "partnerships" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}