"use client";

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

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

    return (
        <ThemeProvider
            defaultButtonVariant="expand-hover"
            defaultTextAnimation="reveal-blur"
            borderRadius="soft"
            contentWidth="compact"
            sizing="largeSmallSizeLargeTitles"
            background="grid"
            cardStyle="outline"
            primaryButtonStyle="gradient"
            secondaryButtonStyle="layered"
            headingFontWeight="medium"
        >
            <ReactLenis root>
                <div id="nav" data-section="nav">
                    <NavbarLayoutFloatingOverlay
                        brandName="The Soap Shop"
                        navItems={[
                            { name: "Home", id: "/" },
                            { name: "Shop", id: "products" },
                            { name: "About", id: "about" },
                            { name: "Reviews", id: "testimonials" },
                            { name: "FAQ", id: "faq" },
                            { name: "Contact", id: "contact" }
                        ]}
                        button={{ text: "Shop 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="The Soap Shop Blog"
                            description="Discover the art of handcrafted organic soap making, skincare tips, and natural living insights from our expert artisans."
                            textboxLayout="default"
                            useInvertedBackground={false}
                            animationType="slide-up"
                            carouselMode="buttons"
                            tag="Blog"
                        />
                    </div>
                )}

                <div id="footer" data-section="footer">
                    <FooterMedia
                        imageSrc="http://img.b2bpic.net/free-photo/clean-bathroom-minimal-home-decor_53876-134402.jpg?_wi=2"
                        imageAlt="Footer background"
                        logoText="The Soap Shop"
                        copyrightText="© 2025 The Soap Shop. Handcrafted organic soap bars."
                        columns={[
                            {
                                title: "Shop",                                items: [
                                    { label: "All Products", href: "#products" },
                                    { label: "Best Sellers", href: "#products" },
                                    { label: "Bundles", href: "#products" },
                                    { label: "Gift Sets", href: "#products" }
                                ]
                            },
                            {
                                title: "Company",                                items: [
                                    { label: "About Us", href: "#about" },
                                    { label: "Ingredients", href: "#about" },
                                    { label: "Our Story", href: "#about" },
                                    { label: "Contact", href: "#contact" }
                                ]
                            },
                            {
                                title: "Legal",                                items: [
                                    { label: "Privacy Policy", href: "#" },
                                    { label: "Terms & Conditions", href: "#" },
                                    { label: "Shipping Info", href: "#" },
                                    { label: "Returns", href: "#" }
                                ]
                            }
                        ]}
                    />
                </div>
            </ReactLenis>
        </ThemeProvider>
    );
}