"use client";

import { ThemeProvider } from "@/providers/themeProvider/ThemeProvider";
import { useBlogPosts } from "@/hooks/useBlogPosts";
import NavbarStyleCentered from '@/components/navbar/NavbarStyleCentered/NavbarStyleCentered';
import FeatureCardTwentyFour from '@/components/sections/feature/FeatureCardTwentyFour';

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

    return (
        <ThemeProvider
            defaultButtonVariant="icon-arrow"
            defaultTextAnimation="entrance-slide"
            borderRadius="soft"
            contentWidth="compact"
            sizing="largeSmallSizeMediumTitles"
            background="blurBottom"
            cardStyle="glass-depth"
            primaryButtonStyle="double-inset"
            secondaryButtonStyle="layered"
            headingFontWeight="light"
        >
            <div id="nav" data-section="nav">
                <NavbarStyleCentered
                    navItems={[
                        { name: "Home", id: "/" },
                        { name: "Blog", id: "/blog" },
                        { name: "Shop", id: "/shop" },
                    ]}
                    button={{ text: "Shop Now", href: "/shop" }}
                    brandName="Dring Together"
                />
            </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">
                    <FeatureCardTwentyFour
                        features={posts.map(post => ({
                            id: post.id,
                            title: post.title,
                            author: post.author || 'Dring Together',
                            description: post.excerpt,
                            tags: post.tags || [],
                            imageSrc: post.image,
                            imageAlt: post.title,
                        }))}
                        title="Latest Articles"
                        description="Insights and updates from our team"
                        animationType="slide-up"
                        textboxLayout="default"
                        useInvertedBackground={false}
                    />
                </div>
            )}
        </ThemeProvider>
    );
}
