"use client";

import ReactLenis from "lenis/react";
import BlogCardOne from "@/components/sections/blog/BlogCardOne";
import FooterBaseReveal from '@/components/sections/footer/FooterBaseReveal';
import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import NavbarLayoutFloatingInline from '@/components/navbar/NavbarLayoutFloatingInline';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="elastic-effect"
            defaultTextAnimation="entrance-slide"
            borderRadius="rounded"
            contentWidth="medium"
            sizing="medium"
            background="noise"
            cardStyle="gradient-mesh"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="glass"
            headingFontWeight="semibold"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingInline
                        brandName="Brew Haven"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Menu", id: "/menu" },
                            { name: "About", id: "/about" },
                            { name: "Contact", id: "/contact" }
                        ]}
                        button={{ text: "Order Now", href: "/menu" }}
                    />
                </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="Coffee Chronicles"
                            description="Discover the art of coffee making, brewing techniques, and the stories behind our favorite beans"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                            tagAnimation="opacity"
                            buttonAnimation="opacity"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterBaseReveal
                        columns={[
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "/about" },
                                    { label: "Our Mission", href: "/about" },
                                    { label: "Careers", href: "#" }
                                ]
                            },
                            {
                                title: "Menu",                                items: [
                                    { label: "Coffee", href: "/menu" },
                                    { label: "Tea & Alternatives", href: "/menu" },
                                    { label: "Pastries", href: "/menu" }
                                ]
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact Us", href: "/contact" },
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "Privacy Policy", href: "#" }
                                ]
                            }
                        ]}
                        copyrightText="© 2025 Brew Haven | Crafted with care"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}