From ec8e6013322c4401b18d1b09eff76ddff3d18ad6 Mon Sep 17 00:00:00 2001 From: Elijah Date: Sat, 27 Jun 2026 20:48:19 -0700 Subject: [PATCH] feat: Allow inline editing of both name and description for decks and quizzes --- .../[classSlug]/flashcards/page.tsx | 64 ++++++++------ .../(protected)/[classSlug]/quizzes/page.tsx | 84 +++++++++++++++++-- 2 files changed, 113 insertions(+), 35 deletions(-) diff --git a/src/app/(protected)/[classSlug]/flashcards/page.tsx b/src/app/(protected)/[classSlug]/flashcards/page.tsx index 096b9d5..9c773b9 100644 --- a/src/app/(protected)/[classSlug]/flashcards/page.tsx +++ b/src/app/(protected)/[classSlug]/flashcards/page.tsx @@ -30,6 +30,7 @@ export default function FlashcardsPage() { const [classId, setClassId] = useState(""); const [editingId, setEditingId] = useState(null); const [editName, setEditName] = useState(""); + const [editDescription, setEditDescription] = useState(""); const fetchDecks = useCallback(async (cId: string) => { try { @@ -77,10 +78,10 @@ export default function FlashcardsPage() { await fetch(`/api/decks/${id}`, { method: "PATCH", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ name: editName.trim() }), + body: JSON.stringify({ name: editName.trim(), description: editDescription.trim() || null }), }); setDecks((prev) => - prev.map((d) => (d.id === id ? { ...d, name: editName.trim() } : d)) + prev.map((d) => (d.id === id ? { ...d, name: editName.trim(), description: editDescription.trim() || null } : d)) ); setEditingId(null); } @@ -148,38 +149,48 @@ export default function FlashcardsPage() { className="group flex flex-col bg-bg-surface rounded-xl border border-border-light shadow-[var(--shadow-card)] hover:shadow-[var(--shadow-card-hover)] hover:border-primary/20 transition-all duration-300 h-full" >
- {/* Name (editable) */} + {/* Name and Description (editable) */} {editingId === deck.id ? ( -
+
setEditName(e.target.value)} - onKeyDown={(e) => e.key === "Enter" && handleRename(deck.id)} + placeholder="Deck Name" autoFocus - className="flex-1 px-3 py-1.5 rounded-lg border border-border bg-bg-surface-alt/50 text-text-heading text-sm focus:outline-none focus:ring-2 focus:ring-primary/30" + className="w-full px-3 py-1.5 rounded-lg border border-border bg-bg-surface-alt/50 text-text-heading text-sm font-semibold focus:outline-none focus:ring-2 focus:ring-primary/30" /> - - +