2025-05-11 00:37:32 -04:00
|
|
|
"use client";
|
|
|
|
|
|
|
|
|
|
import Image from 'next/image';
|
2025-05-11 08:53:46 -04:00
|
|
|
import { StreamDto } from '../../../common/dtos/streamDto';
|
2025-05-11 00:37:32 -04:00
|
|
|
import { useEffect, useState } from 'react';
|
2025-05-12 09:17:05 -04:00
|
|
|
import { useRouter } from 'next/navigation';
|
2025-05-11 00:37:32 -04:00
|
|
|
|
|
|
|
|
type PodcastSummaryType = {
|
2025-05-11 08:53:46 -04:00
|
|
|
stream?: string | string[];
|
2025-05-11 00:37:32 -04:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default function PodcastSummary({ stream }: PodcastSummaryType) {
|
2025-05-12 09:17:05 -04:00
|
|
|
|
|
|
|
|
const [summaryData, setSummaryData] = useState<StreamDto>(),
|
|
|
|
|
router = useRouter(),
|
|
|
|
|
handleNavigation = (url?: string) => {
|
|
|
|
|
if (url) {
|
|
|
|
|
router.push(url);
|
|
|
|
|
}
|
|
|
|
|
};
|
2025-05-11 00:37:32 -04:00
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/${stream}`)
|
|
|
|
|
.then((res) => res.json())
|
|
|
|
|
.then((data) => setSummaryData(data));
|
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
|
|
if (!summaryData) {
|
|
|
|
|
return <p>Loading...</p>;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className="w-full h-auto shadow-md overflow-hidden flex flex-col bg-purple-200">
|
|
|
|
|
<div className="flex flex-col md:flex-row md:items-start">
|
|
|
|
|
<div className="relative w-full h-[150px] md:w-1/3 md:h-[376] bg-purple-100 flex-shrink-0">
|
2025-05-11 15:47:21 -04:00
|
|
|
<Image unoptimized src={summaryData.imageUrl ?? ''} alt={summaryData.title ?? ''} fill className="object-cover md:object-contain" />
|
2025-05-11 00:37:32 -04:00
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="p-4 flex-grow flex flex-col md:ml-4">
|
|
|
|
|
<h2 className="text-lg font-bold text-gray-800">{summaryData.title}</h2>
|
|
|
|
|
<p className="text-sm text-gray-600">{summaryData.description}</p>
|
|
|
|
|
|
|
|
|
|
<div className="mt-4 text-sm text-gray-500">
|
|
|
|
|
<p><strong>Author:</strong> {summaryData.author}</p>
|
|
|
|
|
<p><strong>Managing Editor:</strong> {summaryData.managingEditor}</p>
|
|
|
|
|
<p><strong>Web Master:</strong> {summaryData.webMaster}</p>
|
|
|
|
|
<p><strong>Language:</strong> {summaryData.language}</p>
|
|
|
|
|
<p><strong>Published Date:</strong> {summaryData.pubDate}</p>
|
|
|
|
|
<p><strong>TTL:</strong> {summaryData.ttl} minutes</p>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
<div className="mt-4">
|
|
|
|
|
<p className="text-sm font-bold text-gray-700">Categories:</p>
|
|
|
|
|
<ul className="list-disc list-inside text-sm text-gray-600">
|
|
|
|
|
{summaryData.categories?.map((category, index) => (
|
|
|
|
|
<li key={index}>{category}</li>
|
|
|
|
|
))}
|
|
|
|
|
</ul>
|
|
|
|
|
</div>
|
|
|
|
|
|
2025-05-12 09:17:05 -04:00
|
|
|
<div className="mt-4 flex justify-start space-x-4">
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => handleNavigation(summaryData.feedUrl)}
|
2025-05-12 09:17:30 -04:00
|
|
|
className='bg-purple-400 hover:bg-purple-500 text-sm px-4 py-2 rounded-sm'
|
2025-05-11 00:37:32 -04:00
|
|
|
>
|
2025-05-12 09:17:05 -04:00
|
|
|
RSS Feed
|
|
|
|
|
</button>
|
|
|
|
|
<button
|
|
|
|
|
onClick={() => handleNavigation(summaryData.siteUrl)}
|
2025-05-12 09:17:30 -04:00
|
|
|
className='bg-purple-400 hover:bg-purple-500 text-sm px-4 py-2 rounded-sm'
|
2025-05-11 00:37:32 -04:00
|
|
|
>
|
|
|
|
|
Visit Site
|
2025-05-12 09:17:05 -04:00
|
|
|
</button>
|
2025-05-11 00:37:32 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|