From 9c01cd538e8978d9d40650a2b5053a9c24ca3b55 Mon Sep 17 00:00:00 2001 From: JSC Date: Sun, 10 Aug 2025 19:41:59 +0200 Subject: [PATCH] feat: enhance PlaylistEditPage with edit mode functionality; add cancel and save options for playlist details --- src/pages/PlaylistEditPage.tsx | 159 ++++++++++++++++++++++++--------- 1 file changed, 116 insertions(+), 43 deletions(-) diff --git a/src/pages/PlaylistEditPage.tsx b/src/pages/PlaylistEditPage.tsx index f675e3a..9891b5e 100644 --- a/src/pages/PlaylistEditPage.tsx +++ b/src/pages/PlaylistEditPage.tsx @@ -10,7 +10,7 @@ import { Label } from '@/components/ui/label' import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card' import { Badge } from '@/components/ui/badge' import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table' -import { AlertCircle, Save, ArrowLeft, Music, Clock, ChevronUp, ChevronDown, GripVertical, Trash2, RefreshCw } from 'lucide-react' +import { AlertCircle, Save, Music, Clock, ChevronUp, ChevronDown, Trash2, RefreshCw, Edit, X, ArrowLeft } from 'lucide-react' import { toast } from 'sonner' import { formatDuration } from '@/utils/format-duration' @@ -25,6 +25,7 @@ export function PlaylistEditPage() { const [soundsLoading, setSoundsLoading] = useState(true) const [error, setError] = useState(null) const [saving, setSaving] = useState(false) + const [isEditMode, setIsEditMode] = useState(false) // Form state const [formData, setFormData] = useState({ @@ -109,8 +110,9 @@ export function PlaylistEditPage() { toast.success('Playlist updated successfully') - // Refresh playlist data + // Refresh playlist data and exit edit mode await fetchPlaylist() + setIsEditMode(false) } catch (err) { const errorMessage = err instanceof Error ? err.message : 'Failed to update playlist' toast.error(errorMessage) @@ -119,6 +121,18 @@ export function PlaylistEditPage() { } } + const handleCancelEdit = () => { + if (playlist) { + // Reset form data to original values + setFormData({ + name: playlist.name, + description: playlist.description || '', + genre: playlist.genre || '' + }) + setIsEditMode(false) + } + } + const handleSetCurrent = async () => { if (!playlist) return @@ -251,16 +265,24 @@ export function PlaylistEditPage() {
+
-

Edit Playlist

+

{playlist.name}

- Modify playlist details and manage sounds + View and manage your playlist

- {!playlist.is_current && ( + {!playlist.is_current && !isEditMode && (