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} `; }