2025-05-12 10:14:57 -04:00
|
|
|
"use client";
|
|
|
|
|
|
2025-05-11 00:37:32 -04:00
|
|
|
import Image from 'next/image';
|
2025-05-11 08:53:46 -04:00
|
|
|
import { PodcastDto } from '../../../common/dtos/podcastDto';
|
2025-05-12 10:12:16 -04:00
|
|
|
import { useState } from 'react';
|
2025-05-11 00:37:32 -04:00
|
|
|
|
|
|
|
|
export default function PodcastCard({
|
|
|
|
|
imageUrl = "https://placehold.co/400",
|
|
|
|
|
title,
|
|
|
|
|
description,
|
|
|
|
|
uploadDate,
|
|
|
|
|
url,
|
|
|
|
|
author,
|
|
|
|
|
}: PodcastDto) {
|
2025-05-12 10:12:16 -04:00
|
|
|
const [descriptionExpanded, setDescriptionExpanded] = useState(false),
|
|
|
|
|
toggleExpand = () => {
|
|
|
|
|
setDescriptionExpanded(!descriptionExpanded);
|
|
|
|
|
};
|
|
|
|
|
|
2025-05-11 00:37:32 -04:00
|
|
|
return (
|
2025-05-12 10:12:16 -04:00
|
|
|
<div className="w-full min-h-[150px] shadow-md rounded-sm overflow-hidden flex m-4 mb-1">
|
2025-05-11 00:37:32 -04:00
|
|
|
<div className="w-[150px] h-full bg-purple-100 flex-shrink-0 relative">
|
2025-05-11 15:29:17 -04:00
|
|
|
<Image unoptimized src={imageUrl} alt={title ?? ''} layout="fill" objectFit="contain" />
|
2025-05-11 00:37:32 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="p-4 flex-grow flex flex-col bg-purple-200">
|
|
|
|
|
<h2 className="text-lg font-bold text-gray-800">{title}</h2>
|
2025-05-12 10:12:16 -04:00
|
|
|
<div
|
|
|
|
|
className={`text-sm text-gray-600 overflow-hidden transition-all duration-300 ${descriptionExpanded ? 'max-h-full' : 'max-h-[30px]'
|
|
|
|
|
}`}
|
|
|
|
|
>
|
|
|
|
|
{description}
|
|
|
|
|
</div>
|
|
|
|
|
<button onClick={toggleExpand} className="mt-2 text-center text-blue-500 hover:underline text-sm self-center">
|
|
|
|
|
{descriptionExpanded ? 'Show Less' : 'Show More'}
|
|
|
|
|
</button>
|
2025-05-11 00:37:32 -04:00
|
|
|
<div className="mt-2 text-sm text-gray-500">
|
|
|
|
|
<p>By: {author}</p>
|
|
|
|
|
<p>Uploaded: {uploadDate}</p>
|
|
|
|
|
</div>
|
|
|
|
|
<a href={url} target="_blank" rel="noopener noreferrer" className="mt-4 text-blue-500 hover:underline text-sm">
|
|
|
|
|
Listen Now
|
|
|
|
|
</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|