From 857455fa6d69c13c177a0643af74577f8c88ef6b Mon Sep 17 00:00:00 2001 From: Justin Walrath Date: Fri, 16 May 2025 08:06:32 -0400 Subject: [PATCH] Various changes * #30 key update on map function * #26 Formatted dates on the podcast cards * #33 Listen now button is a styled link button * Moved Add button to buttons component * #34 Now sort the episodes by default in reverse order by timestamp. --- src/app/[stream]/podcasts/podcastCard.tsx | 25 ++++++++--- src/app/[stream]/podcasts/podcastList.tsx | 6 +-- .../components/buttons/addButton.tsx} | 2 +- ...nloadButton.tsx => downloadIconButton.tsx} | 8 ++-- .../components/buttons/linkIconButton.tsx | 42 +++++++++++++++++++ src/app/page.tsx | 2 +- src/pages/api/[stream]/podcasts.ts | 4 +- 7 files changed, 74 insertions(+), 15 deletions(-) rename src/app/{[stream]/podcasts/addPodcastCard.tsx => common/components/buttons/addButton.tsx} (93%) rename src/app/common/components/buttons/{DownloadButton.tsx => downloadIconButton.tsx} (86%) create mode 100644 src/app/common/components/buttons/linkIconButton.tsx diff --git a/src/app/[stream]/podcasts/podcastCard.tsx b/src/app/[stream]/podcasts/podcastCard.tsx index d76b33d..878e612 100644 --- a/src/app/[stream]/podcasts/podcastCard.tsx +++ b/src/app/[stream]/podcasts/podcastCard.tsx @@ -3,7 +3,8 @@ import Image from 'next/image'; import { PodcastDto } from '@/common/dtos/podcastDto'; import { useState } from 'react'; -import DownloadButton from '@/app/common/components/buttons/DownloadButton'; +import DownloadIconButton from '@/app/common/components/buttons/downloadIconButton'; +import LinkIconButton from '@/app/common/components/buttons/linkIconButton'; export default function PodcastCard({ imageUrl, @@ -39,20 +40,34 @@ export default function PodcastCard({

By: {author}

-

Uploaded: {uploadDate}

+

Uploaded: {uploadDate ? + new Date(Number(uploadDate)).toLocaleDateString("en-US", { + year: "numeric", + month: "long", + day: "numeric" + }) : "Unknown"}

+ {url && + + } - Listen Now + {url && - } diff --git a/src/app/[stream]/podcasts/podcastList.tsx b/src/app/[stream]/podcasts/podcastList.tsx index 6dad439..7daf902 100644 --- a/src/app/[stream]/podcasts/podcastList.tsx +++ b/src/app/[stream]/podcasts/podcastList.tsx @@ -2,8 +2,8 @@ import PodcastCard from './podcastCard'; import { useEffect, useState } from 'react'; -import { PodcastDto } from '../../../common/dtos/podcastDto'; -import AddPodcastCard from './addPodcastCard'; +import { PodcastDto } from '@/common/dtos/podcastDto'; +import AddButton from '@/app/common/components/buttons/addButton'; type PodcastListProps = { stream?: string | string[]; @@ -20,7 +20,7 @@ export default function PodcastList({ stream }: PodcastListProps) { return (
- + { podcastData.map((podcast, index) => (
diff --git a/src/app/[stream]/podcasts/addPodcastCard.tsx b/src/app/common/components/buttons/addButton.tsx similarity index 93% rename from src/app/[stream]/podcasts/addPodcastCard.tsx rename to src/app/common/components/buttons/addButton.tsx index 8812e60..cb9e530 100644 --- a/src/app/[stream]/podcasts/addPodcastCard.tsx +++ b/src/app/common/components/buttons/addButton.tsx @@ -3,7 +3,7 @@ import { useRouter } from 'next/navigation'; import { useState, useEffect } from 'react'; -export default function AddPodcastCard({ stream }: { stream?: string | string[] }) { +export default function AddButton({ stream }: { stream?: string | string[] }) { const router = useRouter(), defaultBottomOffset = 16, [bottomOffset, setBottomOffset] = useState(defaultBottomOffset); diff --git a/src/app/common/components/buttons/DownloadButton.tsx b/src/app/common/components/buttons/downloadIconButton.tsx similarity index 86% rename from src/app/common/components/buttons/DownloadButton.tsx rename to src/app/common/components/buttons/downloadIconButton.tsx index 66e8c76..b102c4f 100644 --- a/src/app/common/components/buttons/DownloadButton.tsx +++ b/src/app/common/components/buttons/downloadIconButton.tsx @@ -1,8 +1,8 @@ "use client"; -import IconExpandTextButton from "./IconExpandTextButton"; +import IconExpandTextButton from "./iconExpandTextButton"; -type DownloadButtonProps = { +type DownloadIconButtonProps = { href: string; iconSrc: string; iconAlt?: string; @@ -13,7 +13,7 @@ type DownloadButtonProps = { disabled?: boolean; }; -export default function DownloadButton({ +export default function DownloadIconButton({ href, iconSrc, iconAlt = "icon", @@ -22,7 +22,7 @@ export default function DownloadButton({ className = "", debounceMs, disabled = false -}: DownloadButtonProps) { +}: DownloadIconButtonProps) { const onClick = (e: React.MouseEvent) => { e.preventDefault(); if (disabled) return; diff --git a/src/app/common/components/buttons/linkIconButton.tsx b/src/app/common/components/buttons/linkIconButton.tsx new file mode 100644 index 0000000..29d9d47 --- /dev/null +++ b/src/app/common/components/buttons/linkIconButton.tsx @@ -0,0 +1,42 @@ +"use client"; + +import IconExpandTextButton from "./iconExpandTextButton"; +import { useRouter } from "next/navigation"; + +type LinkIconButtonProps = { + href: string; + iconSrc: string; + iconAlt?: string; + text: string; + className?: string; + debounceMs?: number; + disabled?: boolean; +}; + +export default function LinkIconButton({ + href, + iconSrc, + iconAlt = "icon", + text, + className = "", + debounceMs, + disabled = false +}: LinkIconButtonProps) { + const router = useRouter(), + onClick = (e: React.MouseEvent) => { + e.preventDefault(); + if (disabled || href == null) return; + router.push(href); + }; + return ( + + ); +} \ No newline at end of file diff --git a/src/app/page.tsx b/src/app/page.tsx index 2cd2b51..66911d2 100644 --- a/src/app/page.tsx +++ b/src/app/page.tsx @@ -79,7 +79,7 @@ export default function Home() {
{podcasts.map(podcast => (