From 5a3f799926290a5748a36d2a1c014f3acad6b0ee Mon Sep 17 00:00:00 2001
From: varutasu <104105839+varutasu@users.noreply.github.com>
Date: Wed, 3 Jun 2026 17:24:43 -0500
Subject: [PATCH] refactor(card-editor): extract search panel component (Brief
1) (#90)
Move the find-card search input and results grid into
CardEditorSearchPanel to start splitting the admin card editor page.
Co-authored-by: Cursor
---
components/CardEditorSearchPanel.js | 95 +++++++++++++++++++++++++++++
pages/admin/card-editor.js | 87 ++++----------------------
2 files changed, 106 insertions(+), 76 deletions(-)
create mode 100644 components/CardEditorSearchPanel.js
diff --git a/components/CardEditorSearchPanel.js b/components/CardEditorSearchPanel.js
new file mode 100644
index 0000000..4bf4e41
--- /dev/null
+++ b/components/CardEditorSearchPanel.js
@@ -0,0 +1,95 @@
+/* eslint-disable @next/next/no-img-element -- External card image URLs; next/image migration is out of scope. */
+
+/**
+ * Admin card editor: search input + result grid for picking a card to edit.
+ */
+export default function CardEditorSearchPanel({
+ searchQuery,
+ onSearchQueryChange,
+ searchLoading,
+ searchResults,
+ onSelectCard,
+}) {
+ return (
+
+
+ Find Card to Edit
+
+
+
+
+ onSearchQueryChange(e.target.value)}
+ className="w-full p-3 rounded-lg border transition-all duration-200"
+ style={{
+ backgroundColor: 'var(--bg-primary)',
+ borderColor: 'var(--border)',
+ color: 'var(--text-primary)',
+ }}
+ />
+
+
+
+ {searchLoading && (
+
+ )}
+
+ {searchResults.length > 0 && (
+
+ {searchResults.map((searchCard) => (
+
onSelectCard(searchCard)}
+ className="p-4 rounded-lg border cursor-pointer transition-all duration-200 hover:shadow-lg hover:scale-105"
+ style={{
+ backgroundColor: 'var(--bg-primary)',
+ borderColor: 'var(--border)',
+ }}
+ >
+
+
+ {searchCard.image_url ? (
+

+ ) : (
+
+ {searchCard.game}
+
+ )}
+
+
+
+ {searchCard.name}
+
+
+ {searchCard.set_name} • {searchCard.game}
+
+
+ {searchCard.rarity}
+
+
+
+
+ ))}
+
+ )}
+
+ );
+}
diff --git a/pages/admin/card-editor.js b/pages/admin/card-editor.js
index 1ab5dfe..bb984f1 100644
--- a/pages/admin/card-editor.js
+++ b/pages/admin/card-editor.js
@@ -4,6 +4,7 @@ import { useRouter } from 'next/router';
import dynamic from 'next/dynamic';
import Layout from '../../components/Layout';
import AdminProtected from '../../components/AdminProtected';
+import CardEditorSearchPanel from '../../components/CardEditorSearchPanel';
// Make this component client-side only to avoid SSR issues
const CardEditor = () => {
@@ -230,82 +231,16 @@ const CardEditor = () => {
- {/* Card Search */}
-
-
- Find Card to Edit
-
-
-
-
- {
- setSearchQuery(e.target.value);
- searchCards(e.target.value);
- }}
- className="w-full p-3 rounded-lg border transition-all duration-200"
- style={{
- backgroundColor: 'var(--bg-primary)',
- borderColor: 'var(--border)',
- color: 'var(--text-primary)'
- }}
- />
-
-
-
- {/* Search Results */}
- {searchLoading && (
-
- )}
-
- {searchResults.length > 0 && (
-
- {searchResults.map((searchCard) => (
-
selectCard(searchCard)}
- className="p-4 rounded-lg border cursor-pointer transition-all duration-200 hover:shadow-lg hover:scale-105"
- style={{
- backgroundColor: 'var(--bg-primary)',
- borderColor: 'var(--border)'
- }}
- >
-
-
- {searchCard.image_url ? (
-

- ) : (
-
- {searchCard.game}
-
- )}
-
-
-
- {searchCard.name}
-
-
- {searchCard.set_name} • {searchCard.game}
-
-
- {searchCard.rarity}
-
-
-
-
- ))}
-
- )}
-
+ {
+ setSearchQuery(value);
+ searchCards(value);
+ }}
+ searchLoading={searchLoading}
+ searchResults={searchResults}
+ onSelectCard={selectCard}
+ />
{/* Card Editor Form */}
{card && (