use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="text-stagger"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="mediumSmall"
            sizing="largeSmall"
            background="noise"
            cardStyle="solid"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="glass"
            headingFontWeight="normal"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Dobry Khlib"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About", id: "about" },
                            { name: "Products", id: "products" },
                            { name: "Testimonials", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Contact", id: "contact" },
                        ]}
                        button={{ text: "Order Now", href: "#products" }}
                    />
                </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="From Our Bakery"
                            description="The latest news, stories, and recipes from the team at Dobry Khlib."
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/white-cheese-bread-with-eggs_140725-3991.jpg?_wi=3"
                        imageAlt="Assortment of freshly baked Ukrainian goods"
                        columns={[
                            {
                                title: "Bakery",                                items: [
                                    { label: "Our Story", href: "#about" },
                                    { label: "Products", href: "#products" },
                                    { label: "Order Online", href: "#products" },
                                ],
                            },
                            {
                                title: "Support",                                items: [
                                    { label: "FAQ", href: "#faq" },
                                    { label: "Contact Us", href: "#contact" },
                                ],
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "/privacy" },
                                    { label: "Terms of Service", href: "/terms" },
                                ],
                            },
                        ]}
                        logoText="Dobry Khlib"
                        copyrightText="© 2024 Dobry Khlib. All rights reserved."
                        onPrivacyClick={() => console.log('Privacy Policy clicked')}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
