From ad466e2f917b4247852ece26ec12011f42b3f534 Mon Sep 17 00:00:00 2001 From: JSC Date: Sat, 16 Aug 2025 21:41:57 +0200 Subject: [PATCH] feat: implement favorites functionality across playlists components --- src/components/playlists/PlaylistRow.tsx | 29 ++++++++++++- src/components/playlists/PlaylistTable.tsx | 4 +- src/components/playlists/PlaylistsHeader.tsx | 20 ++++++++- .../playlists/PlaylistsLoadingStates.tsx | 20 ++++++--- src/lib/api/services/playlists.ts | 6 +++ src/pages/PlaylistsPage.tsx | 43 ++++++++++++++++++- 6 files changed, 108 insertions(+), 14 deletions(-) diff --git a/src/components/playlists/PlaylistRow.tsx b/src/components/playlists/PlaylistRow.tsx index ae2279a..ea0511f 100644 --- a/src/components/playlists/PlaylistRow.tsx +++ b/src/components/playlists/PlaylistRow.tsx @@ -4,15 +4,22 @@ import { TableCell, TableRow } from '@/components/ui/table' import type { Playlist } from '@/lib/api/services/playlists' import { formatDateDistanceToNow } from '@/utils/format-date' import { formatDuration } from '@/utils/format-duration' -import { Calendar, Clock, Edit, Music, Play, User } from 'lucide-react' +import { cn } from '@/lib/utils' +import { Calendar, Clock, Edit, Heart, Music, Play, User } from 'lucide-react' interface PlaylistRowProps { playlist: Playlist onEdit: (playlist: Playlist) => void onSetCurrent: (playlist: Playlist) => void + onFavoriteToggle?: (playlistId: number, isFavorited: boolean) => void } -export function PlaylistRow({ playlist, onEdit, onSetCurrent }: PlaylistRowProps) { +export function PlaylistRow({ playlist, onEdit, onSetCurrent, onFavoriteToggle }: PlaylistRowProps) { + const handleFavoriteToggle = () => { + if (onFavoriteToggle) { + onFavoriteToggle(playlist.id, !playlist.is_favorited) + } + } return ( @@ -76,6 +83,24 @@ export function PlaylistRow({ playlist, onEdit, onSetCurrent }: PlaylistRowProps
+ {onFavoriteToggle && ( + + )}