From 858178d6878229c0ac413d3ea5a4f799d6114ecb Mon Sep 17 00:00:00 2001
From: nsfisis <nsfisis@gmail.com>
Date: Sun, 7 Dec 2025 18:29:26 +0900
Subject: feat(client): add edit card modal with form validation
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

Add EditCardModal component allowing users to edit existing cards.
Includes Edit button on each card in the deck detail page and
comprehensive unit tests.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
---
 src/client/pages/DeckDetailPage.tsx | 19 +++++++++++++++++++
 1 file changed, 19 insertions(+)

(limited to 'src/client/pages/DeckDetailPage.tsx')

diff --git a/src/client/pages/DeckDetailPage.tsx b/src/client/pages/DeckDetailPage.tsx
index 9fce7b7..57e4af9 100644
--- a/src/client/pages/DeckDetailPage.tsx
+++ b/src/client/pages/DeckDetailPage.tsx
@@ -2,6 +2,7 @@ import { useCallback, useEffect, useState } from "react";
 import { Link, useParams } from "wouter";
 import { ApiClientError, apiClient } from "../api";
 import { CreateCardModal } from "../components/CreateCardModal";
+import { EditCardModal } from "../components/EditCardModal";
 
 interface Card {
 	id: string;
@@ -36,6 +37,7 @@ export function DeckDetailPage() {
 	const [isLoading, setIsLoading] = useState(true);
 	const [error, setError] = useState<string | null>(null);
 	const [isCreateModalOpen, setIsCreateModalOpen] = useState(false);
+	const [editingCard, setEditingCard] = useState<Card | null>(null);
 
 	const fetchDeck = useCallback(async () => {
 		if (!deckId) return;
@@ -239,6 +241,13 @@ export function DeckDetailPage() {
 												<span>Lapses: {card.lapses}</span>
 											</div>
 										</div>
+										<button
+											type="button"
+											onClick={() => setEditingCard(card)}
+											style={{ marginLeft: "1rem" }}
+										>
+											Edit
+										</button>
 									</div>
 								</li>
 							))}
@@ -255,6 +264,16 @@ export function DeckDetailPage() {
 					onCardCreated={fetchCards}
 				/>
 			)}
+
+			{deckId && (
+				<EditCardModal
+					isOpen={editingCard !== null}
+					deckId={deckId}
+					card={editingCard}
+					onClose={() => setEditingCard(null)}
+					onCardUpdated={fetchCards}
+				/>
+			)}
 		</div>
 	);
 }
-- 
cgit v1.2.3-70-g09d2

