From 2ed5099fd609dfa40ea269c3ed68b17a318a01f2 Mon Sep 17 00:00:00 2001 From: Randall Stillwell Date: Sat, 13 Jun 2026 00:45:53 -0500 Subject: [PATCH] refactor(deck): extract grouped card list panel (Brief 2) Move the grouped card list and empty-deck state into DeckDetailCardList; page header + stats sidebar remain inline for Brief 3. Co-authored-by: Cursor --- components/DeckDetailCardList.js | 91 +++++++++++++++++++++++++++++++ pages/deck/[id].js | 93 +------------------------------- 2 files changed, 93 insertions(+), 91 deletions(-) create mode 100644 components/DeckDetailCardList.js diff --git a/components/DeckDetailCardList.js b/components/DeckDetailCardList.js new file mode 100644 index 0000000..217e7fa --- /dev/null +++ b/components/DeckDetailCardList.js @@ -0,0 +1,91 @@ +/* eslint-disable @next/next/no-img-element -- External card image URLs; next/image migration is out of scope. */ +import { ManaCost } from './ManaSymbols'; + +export default function DeckDetailCardList({ cards, groupedCards }) { + const isEmpty = !cards || cards.length === 0; + + return ( +
+
+ {isEmpty ? ( +
+
🃏
+

+ Empty Deck +

+

+ This deck doesn't have any cards yet +

+
+ ) : ( +
+ {Object.entries(groupedCards) + .sort(([a], [b]) => a.localeCompare(b)) + .map(([group, groupCards]) => ( +
+

+ {group} ({groupCards.reduce((sum, card) => sum + card.quantity, 0)}) +

+
+ {groupCards + .sort((a, b) => a.name.localeCompare(b.name)) + .map((card) => ( +
+ {card.image_url && ( + {card.name} + )} +
+
+

+ {card.name} +

+ + {card.quantity}x + +
+

+ {card.set_name} +

+
+ {card.mana_cost && ( + + )} + {card.rarity && ( + {card.rarity} + )} +
+
+
+ ))} +
+
+ ))} +
+ )} +
+
+ ); +} diff --git a/pages/deck/[id].js b/pages/deck/[id].js index 54d3808..4e546ee 100644 --- a/pages/deck/[id].js +++ b/pages/deck/[id].js @@ -1,10 +1,9 @@ -/* eslint-disable @next/next/no-img-element -- External or generated image URLs; next/image migration is out of scope. */ import { useState, useEffect } from 'react'; import { useRouter } from 'next/router'; import Link from 'next/link'; import Layout from '../../components/Layout'; +import DeckDetailCardList from '../../components/DeckDetailCardList'; import DeckDetailStatsSidebar from '../../components/DeckDetailStatsSidebar'; -import { ManaCost } from '../../components/ManaSymbols'; import { Button } from '../../components/ui'; import { computeDeckStats } from '../../lib/deck-builder-stats.js'; import { groupDeckCards } from '../../lib/deck-detail-grouping.js'; @@ -164,95 +163,7 @@ export default function DeckDetail() { onGroupByChange={setGroupBy} /> - {/* Card List */} -
-
- {deck.cards && deck.cards.length === 0 ? ( -
-
🃏
-

- Empty Deck -

-

- This deck doesn't have any cards yet -

-
- ) : ( -
- {Object.entries(groupedCards) - .sort(([a], [b]) => a.localeCompare(b)) - .map(([group, cards]) => ( -
-

- {group} ({cards.reduce((sum, card) => sum + card.quantity, 0)}) -

-
- {cards - .sort((a, b) => a.name.localeCompare(b.name)) - .map((card) => ( -
- {card.image_url && ( - {card.name} - )} -
-
-

- {card.name} -

- - {card.quantity}x - -
-

- {card.set_name} -

-
- {card.mana_cost && ( - - )} - {card.rarity && ( - {card.rarity} - )} -
-
-
- ))} -
-
- ))} -
- )} -
-
+ -- 2.45.2