"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="elastic-effect"
            defaultTextAnimation="reveal-blur"
            borderRadius="rounded"
            contentWidth="medium"
            sizing="large"
            background="floatingGradient"
            cardStyle="glass-depth"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="solid"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="Zoryana Bakery"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "About Us", id: "/#about" },
                            { name: "Products", id: "/#products" },
                            { name: "Testimonials", id: "/#testimonials" },
                            { name: "FAQ", id: "/#faq" },
                            { name: "Contact", id: "/#contact" },
                        ]}
                        button={{ text: "Order Now", href: "/#contact" }}
                        className="py-4 px-6 md:px-8"
                        buttonClassName="px-5 py-2 text-sm md:text-base"
                        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">
                        <BlogCardThree
                            blogs={posts}
                            title="From Our Ovens"
                            description="Discover the latest news, recipes, and stories from Zoryana Bakery."
                            animationType="slide-up"
                            textboxLayout="default"
                            useInvertedBackground={false}
                            carouselMode="buttons"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="https://img.b2bpic.net/free-photo/bakery-shop-gourmet-concept_53876-163311.jpg"
                        imageAlt="Exterior of Zoryana Bakery at dusk"
                        columns={[
                            {
                                title: "Quick Links",                                items: [
                                    { label: "Home", href: "/" },
                                    { label: "Products", href: "/#products" },
                                    { label: "About Us", href: "/#about" },
                                ],
                            },
                            {
                                title: "Connect",                                items: [
                                    { label: "Contact Us", href: "/#contact" },
                                    { label: "FAQ", href: "/#faq" },
                                ],
                            },
                            {
                                title: "Follow Us",                                items: [
                                    { label: "Facebook", href: "https://facebook.com/zoryanabakery" },
                                    { label: "Instagram", href: "https://instagram.com/zoryanabakery" },
                                ],
                            },
                        ]}
                        logoText="Zoryana Bakery"
                        copyrightText="© 2024 Zoryana Bakery. All rights reserved."
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}
