added a fix for variant selection (without it cards with multiple versions would add all at form submit)

This commit is contained in:
Zach Harding
2026-04-05 16:32:44 -04:00
parent d06c6fb9bf
commit 5d716a4d8e
3 changed files with 23 additions and 9 deletions

View File

@@ -181,6 +181,9 @@ for (const price of card?.prices ?? []) {
}
}
// ── Derive distinct variants available for this card ─────────────────────
const availableVariants = [...new Set(cardSkus.map(s => s.variant))].sort();
const ebaySearchUrl = (card: any) => {
return `https://www.ebay.com/sch/i.html?_nkw=${encodeURIComponent(card?.productUrlName)}+${encodeURIComponent(card?.set?.setUrlName)}+${encodeURIComponent(card?.number)}&LH_Sold=1&Graded=No&_dcat=183454`;
};
@@ -360,13 +363,13 @@ const altSearchUrl = (card: any) => {
})}
{hasAccess && (
<div class="tab-pane fade" id="nav-vendor" role="tabpanel" aria-labelledby="nav-vendor" tabindex="0">
<div class="row g-3">
<div class="row g-4">
<div class="col-12 col-md-6">
<h6 class="mt-1 mb-2">Add {card?.productName} to inventory</h6>
<form id="inventoryForm" data-inventory-form novalidate>
<div class="row gx-3 gy-1">
<div class="col-4">
<div class="col-3">
<label for="quantity" class="form-label">Quantity</label>
<input
type="number"
@@ -381,7 +384,7 @@ const altSearchUrl = (card: any) => {
<div class="invalid-feedback">Required.</div>
</div>
<div class="col-8">
<div class="col-9">
<div class="d-flex justify-content-between align-items-start gap-2 flex-wrap">
<label for="purchasePrice" class="form-label">
Purchase price
@@ -486,6 +489,9 @@ const altSearchUrl = (card: any) => {
<label class="btn btn-cond-dmg" for="cond-dmg">DMG</label>
</div>
</div>
<input type="hidden" name="variant" value={card?.variant} />
<div class="col-12">
<label for="catalogName" class="form-label">
Catalog
@@ -534,7 +540,7 @@ const altSearchUrl = (card: any) => {
<h6 class="mt-1 mb-2">Inventory entries for {card?.productName}</h6>
<!-- Empty state -->
<div class="alert alert-dark rounded-4 d-none" id="inventoryEmptyState">
<div class="alert alert-dark border-0 rounded-4 d-none" id="inventoryEmptyState">
<div class="fw-medium mb-1">No inventory entries yet</div>
<div class="text-secondary small">
Once you add copies of this card, they'll show up here.