import { Play, Pause, Clock, Building2 } from "lucide-react";
import type { PodcastWithRelations } from "../../../server/db";
interface Props {
podcast: PodcastWithRelations;
isPlaying: boolean;
onPlay: () => void;
}
// Palette de couleurs pour les artworks (basée sur l'ID du podcast)
const ARTWORK_COLORS = [
"from-blue-500 to-indigo-600",
"from-violet-500 to-purple-700",
"from-emerald-500 to-teal-600",
"from-orange-500 to-red-600",
"from-cyan-500 to-blue-600",
"from-rose-500 to-pink-600",
"from-amber-500 to-orange-600",
"from-indigo-500 to-blue-700",
];
function WaveformIcon() {
return (
{[3, 5, 4, 6, 3, 5, 4].map((h, i) => (
))}
);
}
function formatDuration(s?: number | null): string | null {
if (!s) return null;
const m = Math.floor(s / 60);
const sec = s % 60;
return `${m}:${sec.toString().padStart(2, "0")}`;
}
export default function PodcastCard({ podcast, isPlaying, onPlay }: Props) {
const duration = formatDuration(podcast.dureeSecondes);
const colorClass = ARTWORK_COLORS[podcast.id % ARTWORK_COLORS.length];
return (
{/* Barre colorée en haut */}
{/* Artwork */}
{isPlaying ? (
) : (
)}
{/* Indicateur "en cours" */}
{isPlaying && (
)}
{/* Contenu */}
{podcast.titre}
{podcast.resume}
{/* Meta row */}
{podcast.etablissementNom}
{duration && (
{duration}
)}
{/* Mots-clés */}
{podcast.motsCles.length > 0 && (
{podcast.motsCles.slice(0, 3).map((mk) => (
{mk.label}
))}
{podcast.motsCles.length > 3 && (
+{podcast.motsCles.length - 3}
)}
)}
{/* Bouton play */}
{podcast.audioUrl && (
)}
);
}