From d7acbebc9ce5ebe2032fa01a3fa092d8f117883c Mon Sep 17 00:00:00 2001 From: fullsizemalt <106900403+fullsizemalt@users.noreply.github.com> Date: Wed, 24 Dec 2025 16:20:29 -0800 Subject: [PATCH] feat: Sequences edit dialog with song reordering and management --- frontend/app/admin/sequences/page.tsx | 153 +++++++++++++++++++++++--- 1 file changed, 136 insertions(+), 17 deletions(-) diff --git a/frontend/app/admin/sequences/page.tsx b/frontend/app/admin/sequences/page.tsx index de83915..9a08692 100644 --- a/frontend/app/admin/sequences/page.tsx +++ b/frontend/app/admin/sequences/page.tsx @@ -40,6 +40,127 @@ interface Song { slug: string } +// Edit Sequence Form Component +function EditSequenceForm({ + sequence, + allSongs, + token, + onSave, + onCancel +}: { + sequence: Sequence + allSongs: Song[] + token: string + onSave: () => void + onCancel: () => void +}) { + const [name, setName] = useState(sequence.name) + const [description, setDescription] = useState(sequence.description || "") + const [notes, setNotes] = useState(sequence.notes || "") + const [songIds, setSongIds] = useState(sequence.songs.map(s => s.song_id)) + const [songSearch, setSongSearch] = useState("") + const [saving, setSaving] = useState(false) + + const filteredSongs = allSongs.filter(s => + s.title.toLowerCase().includes(songSearch.toLowerCase()) && + !songIds.includes(s.id) + ).slice(0, 15) + + const addSong = (id: number) => setSongIds([...songIds, id]) + const removeSong = (id: number) => setSongIds(songIds.filter(sid => sid !== id)) + const moveSong = (index: number, direction: -1 | 1) => { + const newIds = [...songIds] + const newIndex = index + direction + if (newIndex < 0 || newIndex >= newIds.length) return + [newIds[index], newIds[newIndex]] = [newIds[newIndex], newIds[index]] + setSongIds(newIds) + } + + const handleSave = async () => { + setSaving(true) + try { + const res = await fetch(`${getApiUrl()}/sequences/${sequence.id}`, { + method: "PATCH", + headers: { + "Content-Type": "application/json", + Authorization: `Bearer ${token}` + }, + body: JSON.stringify({ name, description, notes, song_ids: songIds }) + }) + if (res.ok) onSave() + } catch (e) { + console.error("Failed to save", e) + } finally { + setSaving(false) + } + } + + return ( +
+
+ + setName(e.target.value)} /> +
+
+ +