"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 BlogCardThree from '@/components/sections/blog/BlogCardThree';
import { useBlogPosts } from "@/hooks/useBlogPosts";

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

    return (
        <ThemeProvider
            defaultButtonVariant="hover-bubble"
            defaultTextAnimation="entrance-slide"
            borderRadius="rounded"
            contentWidth="mediumSmall"
            sizing="mediumLargeSizeLargeTitles"
            background="fluid"
            cardStyle="solid"
            primaryButtonStyle="inset-glow"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About Us", id: "about" },
                            { name: "Menu", id: "menu" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Contact", id: "contact" },
                        ]}
                        brandName="Смак України"
                        button={{ text: "Order Now", href: "#contact" }}
                        buttonClassName="bg-primary-cta text-primary-cta-text"
                        buttonTextClassName="text-primary-cta-text"
                    />
                </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 stories from the heart of Ukrainian baking."
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/vertical-view-whole-black-bread-brown-towel-potteries-dark-colors-surface_179666-24652.jpg?_wi=3"
                        imageAlt="Traditional Ukrainian bakery display"
                        logoText="Смак України"
                        columns={[
                            {
                                title: "Bakery",                                items: [
                                    { label: "Our Menu", href: "#menu" },
                                    { label: "Our Story", href: "#about" },
                                    { label: "FAQ", href: "#faq" },
                                ],
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact Us", href: "#contact" },
                                    { label: "Instagram", href: "https://instagram.com" },
                                    { label: "Facebook", href: "https://facebook.com" },
                                ],
                            },
                        ]}
                        copyrightText="© 2024 Smak Ukrainy. All rights reserved."
                        useInvertedBackground={false}
                        logoTextClassName="text-foreground"
                        columnTitleClassName="text-foreground"
                        columnItemClassName="text-foreground"
                        copyrightTextClassName="text-foreground"
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
