import { mainFont } from '@/app/layout'
import { PostCategory } from '@/types/entities'

interface PostCardProps {
    thumbnail_src?: string
    show_thumbnail?: boolean
    title: string
    show_description?: boolean
    description?: string
    post_href: string
    date?: string
    show_date?: boolean
    categories?: PostCategory[]
    show_categories?: boolean
}

const PostCard = ({
    title,
    show_description = false,
    description,
    show_thumbnail = false,
    thumbnail_src,
    post_href,
    date,
    show_date = false,
    categories,
    show_categories = false
}: PostCardProps) => {
    return (
        <div className={`${mainFont.className} text-[#0063A7] card sm:card-side bg-base-100 h-1/1 w-full shadow-sm`}>
            {show_thumbnail && thumbnail_src &&
                <figure className='sm:h-full sm:w-full'>
                    <a href={post_href} className='w-full h-full'>
                        <img
                            className='object-cover w-full h-full'
                            src={thumbnail_src}
                            alt="Shoes" />
                    </a>

                </figure>
            }

            <div className="card-body">
                <a href={post_href} className={`card-title`}>
                    {title}
                </a>
                {description && show_description &&
                    <p className='font-medium text-base-content'>
                        {description}
                    </p>
                }
                <div className="card-actions items-center justify-between">
                    {date && show_date &&
                        <span>{date}</span>
                    }
                    <div className='flex gap-2'>
                        {categories && show_categories &&
                            categories.map((cat, index) => (
                                <a key={`category-${cat.id}`} href={cat.slug} className="badge badge-outline">
                                    {cat.name}
                                </a>
                            ))
                        }
                    </div>

                </div>
            </div>

        </div>

    )
}

export default PostCard