From 30dfb25cf703dbdfcdd6dec47c6d5ba7f33eb414 Mon Sep 17 00:00:00 2001 From: funman300 Date: Thu, 25 Jun 2026 17:50:16 -0700 Subject: [PATCH] Phase 18: collection quick-sell button MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each card in the Collection tab now shows a Sell button displaying the quick-sell coin value (computed from overall rating using the same tiers as the backend: 85+→1500c, 80-84→900c, 75-79→600c, 65-74→300c, <65→150c). Clicking calls DELETE /collection/:id with a confirmation prompt, shows a toast with the actual coins received, and refreshes both the collection and the header coin counter. Loan cards show a disabled button instead to prevent accidental early sale. Co-Authored-By: Claude Sonnet 4.6 --- src/dashboard.html | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/dashboard.html b/src/dashboard.html index b66f332..36ed338 100644 --- a/src/dashboard.html +++ b/src/dashboard.html @@ -711,6 +711,26 @@ function statBar(label, val) { `; } +function quickSellValue(overall) { + if (overall >= 85) return 1500; + if (overall >= 80) return 900; + if (overall >= 75) return 600; + if (overall >= 65) return 300; + return 150; +} + +async function quickSellCard(ownedCardId, coinValue, btn) { + if (!confirm(`Quick-sell for ${coinValue.toLocaleString()} coins? This cannot be undone.`)) return; + btn.disabled = true; + try { + const r = await api('DELETE', `/collection/${ownedCardId}`); + showToast(`Sold for ${(r.coins_received || coinValue).toLocaleString()} coins`); + el('hdr-coins').textContent = '…'; + api('GET', '/club').then(c => { el('hdr-coins').textContent = (c.coins ?? 0).toLocaleString() + ' coins'; }).catch(() => {}); + loadCollection(); + } catch (e) { showToast(e.message, true); btn.disabled = false; } +} + function renderPlayerCard(item) { const c = item.card; const ovr = item.effective_overall ?? c.overall; @@ -724,6 +744,11 @@ function renderPlayerCard(item) { isLoan, ].join(''); + const sellCoins = quickSellValue(ovr); + const sellBtn = item.is_loan + ? `` + : ``; + return `
${(c.rarity||'').toUpperCase()}
${ovr}
@@ -735,6 +760,7 @@ function renderPlayerCard(item) { ${statBar('DRI', c.dribbling)}${statBar('DEF', c.defending)}${statBar('PHY', c.physical)}
${pills ? `
${pills}
` : ''} + ${sellBtn} `; }