diff --git a/src/app/[stream]/podcasts/addPodcastCard.tsx b/src/app/[stream]/podcasts/addPodcastCard.tsx index 5143f79..de64e14 100644 --- a/src/app/[stream]/podcasts/addPodcastCard.tsx +++ b/src/app/[stream]/podcasts/addPodcastCard.tsx @@ -1,6 +1,6 @@ import { useRouter } from 'next/navigation'; -export default function AddPodcastCard({ stream }: { stream: string }) { +export default function AddPodcastCard({ stream }: { stream?: string | string[] }) { const router = useRouter(); const handleClick = () => { diff --git a/src/app/[stream]/podcasts/podcastCard.tsx b/src/app/[stream]/podcasts/podcastCard.tsx index 9eb8c3a..96c5baf 100644 --- a/src/app/[stream]/podcasts/podcastCard.tsx +++ b/src/app/[stream]/podcasts/podcastCard.tsx @@ -1,5 +1,5 @@ import Image from 'next/image'; -import { PodcastDto } from '../common/dtos/podcastDto'; +import { PodcastDto } from '../../../common/dtos/podcastDto'; export default function PodcastCard({ imageUrl = "https://placehold.co/400", @@ -12,7 +12,7 @@ export default function PodcastCard({ return (
- {title} + {title
diff --git a/src/app/[stream]/podcasts/podcastList.tsx b/src/app/[stream]/podcasts/podcastList.tsx index b9f8dab..9705650 100644 --- a/src/app/[stream]/podcasts/podcastList.tsx +++ b/src/app/[stream]/podcasts/podcastList.tsx @@ -6,7 +6,7 @@ import { PodcastDto } from '../../../common/dtos/podcastDto'; import AddPodcastCard from './addPodcastCard'; type PodcastListProps = { - stream: string; + stream?: string | string[]; } export default function PodcastList({ stream }: PodcastListProps) { @@ -30,6 +30,7 @@ export default function PodcastList({ stream }: PodcastListProps) { uploadDate={podcast.uploadDate} url={podcast.url} author={podcast.author} + imageUrl={podcast.imageUrl} />
)) diff --git a/src/app/[stream]/podcasts/podcastSummary.tsx b/src/app/[stream]/podcasts/podcastSummary.tsx index 8eb5945..19ce1d4 100644 --- a/src/app/[stream]/podcasts/podcastSummary.tsx +++ b/src/app/[stream]/podcasts/podcastSummary.tsx @@ -1,15 +1,15 @@ "use client"; import Image from 'next/image'; -import { StreamDto } from '../common/dtos/steamDto'; +import { StreamDto } from '../../../common/dtos/streamDto'; import { useEffect, useState } from 'react'; type PodcastSummaryType = { - stream: string; + stream?: string | string[]; }; export default function PodcastSummary({ stream }: PodcastSummaryType) { - const [summaryData, setSummaryData] = useState(null); + const [summaryData, setSummaryData] = useState(); useEffect(() => { fetch(`${process.env.NEXT_PUBLIC_API_BASE_URL}/api/${stream}`) @@ -25,7 +25,7 @@ export default function PodcastSummary({ stream }: PodcastSummaryType) {
- {summaryData.title} + {summaryData.title
diff --git a/src/app/[stream]/publish/publishForm.tsx b/src/app/[stream]/publish/publishForm.tsx index e4e7293..0e98d6e 100644 --- a/src/app/[stream]/publish/publishForm.tsx +++ b/src/app/[stream]/publish/publishForm.tsx @@ -11,7 +11,7 @@ type PodcastDto = { author: string; }; -export default function StreamPublishForm({ stream }: { stream?: string }) { +export default function StreamPublishForm({ stream }: { stream?: string | string[] }) { const { register, handleSubmit, formState: { errors } } = useForm(); const onSubmit: SubmitHandler = (data) => { diff --git a/src/common/dtos/podcastDto.ts b/src/common/dtos/podcastDto.ts index 5ead631..5da9527 100644 --- a/src/common/dtos/podcastDto.ts +++ b/src/common/dtos/podcastDto.ts @@ -1,6 +1,6 @@ export type PodcastDto = { - podcastId: string; - streamId: string; + podcastId?: string; + streamId?: string; imageUrl?: string; title?: string; description?: string; diff --git a/src/common/helpers/data.ts b/src/common/helpers/data.ts index be1dc34..b606205 100644 --- a/src/common/helpers/data.ts +++ b/src/common/helpers/data.ts @@ -28,7 +28,7 @@ export const preparePodcastItem = (podcast: PodcastDto) => { imageUrl: convertUrlToPublic(podcast.imageUrl), url: fileUrl, enclosure: { - url: fileUrl, + url: fileUrl ?? '', type: getFileMimeType(podcast.url ?? ''), size: fileSize } diff --git a/src/pages/api/[stream]/podcasts.ts b/src/pages/api/[stream]/podcasts.ts index 0591e23..0ee89bd 100644 --- a/src/pages/api/[stream]/podcasts.ts +++ b/src/pages/api/[stream]/podcasts.ts @@ -5,10 +5,11 @@ import { v4 as uuidv4 } from 'uuid'; import multiparty from 'multiparty'; import { getPodcasts, publishPodcast } from '../../../common/data/db'; import { PodcastDto } from '../../../common/dtos/podcastDto'; +import { preparePodcastItem } from '../../../common/helpers/data'; const get = async (req: NextApiRequest, res: NextApiResponse) => { const stream = req.query.stream as string, - podcasts = await getPodcasts(stream); + podcasts = (await getPodcasts(stream as string)).map(preparePodcastItem); res.status(200).json(podcasts); };