"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="shift-hover"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="mediumLarge"
            sizing="mediumLargeSizeMediumTitles"
            background="fluid"
            cardStyle="inset"
            primaryButtonStyle="primary-glow"
            secondaryButtonStyle="glass"
            headingFontWeight="light"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Menu", id: "products" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "Contact", id: "contact" },
                        ]}
                        brandName="Смачна Випічка"
                        button={{ text: "Order Now", href: "#products" }}
                        className="py-4 px-6"
                        buttonClassName="px-5 py-2"
                        buttonTextClassName="font-medium"
                    />
                </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="Insights and updates from our team"
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/ripe-big-pumpkin-burlap_114579-29487.jpg?_wi=2"
                        imageAlt="Rustic fabric or dough texture as footer background."
                        logoText="Смачна Випічка"
                        columns={[
                            {
                                title: "Menu",                                items: [
                                    { label: "Breads", href: "#products" },
                                    { label: "Pastries", href: "#products" },
                                    { label: "Custom Cakes", href: "#contact" },
                                ],
                            },
                            {
                                title: "About Us",                                items: [
                                    { label: "Our Story", href: "#about" },
                                    { label: "Reviews", href: "#testimonials" },
                                ],
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "FAQ", href: "#faq" },
                                    { label: "Contact", href: "#contact" },
                                ],
                            },
                        ]}
                        copyrightText="© 2024 Смачна Випічка. All rights reserved."
                        mediaClassName="opacity-60"
                        className="text-foreground"
                        containerClassName="bg-card"
                        logoTextClassName="text-foreground"
                        columnTitleClassName="text-foreground"
                        columnItemClassName="text-foreground/80 hover:text-foreground"
                        copyrightTextClassName="text-foreground/60"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
