"use client";

import ReactLenis from "lenis/react";
import BlogCardThree from '@/components/sections/blog/BlogCardThree';
import FooterBase from '@/components/sections/footer/FooterBase';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import type { FooterColumn } from "@/components/shared/FooterColumns";
import NavbarStyleApple from '@/components/navbar/NavbarStyleApple/NavbarStyleApple';
import { useBlogPosts } from "@/hooks/useBlogPosts";

const footerColumns: FooterColumn[] = [
    {
        title: "Navigation",        items: [
            { label: "Home", href: "/" },
            { label: "About", href: "about" },
            { label: "Projects", href: "projects" },
            { label: "Contact", href: "contact" },
        ],
    },
    {
        title: "Social",        items: [
            { label: "LinkedIn", href: "https://linkedin.com" },
            { label: "Twitter", href: "https://twitter.com" },
            { label: "Instagram", href: "https://instagram.com" },
            { label: "Dribbble", href: "https://dribbble.com" },
        ],
    },
    {
        title: "Legal",        items: [
            { label: "Privacy Policy", href: "/privacy" },
            { label: "Terms of Service", href: "/terms" },
        ],
    },
];

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

    return (
        <ThemeProvider
            defaultButtonVariant="hover-magnetic"
            defaultTextAnimation="background-highlight"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="mediumLargeSizeMediumTitles"
            background="aurora"
            cardStyle="gradient-mesh"
            primaryButtonStyle="flat"
            secondaryButtonStyle="solid"
            headingFontWeight="bold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarStyleApple
                        brandName="Portfolio"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Projects", id: "projects" },
                            { name: "Skills", id: "skills" },
                            { name: "Contact", id: "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">
                            <BlogCardThree
                                blogs={posts}
                                title="Featured Articles"
                                description="Explore our latest insights and discoveries"
                                textboxLayout="default"
                                useInvertedBackground="noInvert"
                                carouselMode="buttons"
                                animationType="slide-up"
                                tag="Blog"
                                uniformGridCustomHeightClasses="min-h-[600px]"
                            />
                        </div>
                    )}

                    <div id="footer" data-section="footer">
                        <FooterBase
                            logoText="Portfolio"
                            copyrightText="© 2024 Creative Designer. All rights reserved."
                            columns={footerColumns}
                        />
                    </div>
            </ReactLenis>
        </ThemeProvider>
    );
}