From f0ee662450a0f15286aa8307ee9ba8a2c65952e5 Mon Sep 17 00:00:00 2001 From: zach Date: Thu, 16 Jul 2026 08:53:33 -0400 Subject: [PATCH] Updated inventory modal styling and added inventory button to card grid --- src/pages/dashboard.astro | 19 +-- src/pages/partials/card-modal.astro | 2 +- src/pages/partials/cards.astro | 4 +- src/pages/partials/inventory-modal.astro | 168 ++++++++++++++++------- 4 files changed, 130 insertions(+), 63 deletions(-) diff --git a/src/pages/dashboard.astro b/src/pages/dashboard.astro index afbd64d..b4691be 100644 --- a/src/pages/dashboard.astro +++ b/src/pages/dashboard.astro @@ -47,13 +47,6 @@ const catalogs = catalogRows -
-
+
+
diff --git a/src/pages/partials/card-modal.astro b/src/pages/partials/card-modal.astro index a199e1d..ba317a3 100644 --- a/src/pages/partials/card-modal.astro +++ b/src/pages/partials/card-modal.astro @@ -473,7 +473,7 @@ const altSearchUrl = (card: any) => {
- Type a name or pick an existing catalog. + Enter a name or pick an existing catalog.
diff --git a/src/pages/partials/cards.astro b/src/pages/partials/cards.astro index 9c1b6d1..6e16d81 100644 --- a/src/pages/partials/cards.astro +++ b/src/pages/partials/cards.astro @@ -7,8 +7,8 @@ export const prerender = false; import * as util from 'util'; // auth check for inventory management features -//const { canAddInventory } = Astro.locals; -const canAddInventory = false; +const { canAddInventory } = Astro.locals; +// const canAddInventory = false; // all the facet fields we want to use for filtering const facetFields:any = { diff --git a/src/pages/partials/inventory-modal.astro b/src/pages/partials/inventory-modal.astro index 868f013..39020c1 100644 --- a/src/pages/partials/inventory-modal.astro +++ b/src/pages/partials/inventory-modal.astro @@ -48,7 +48,17 @@ const purchaseDate = inv?.createdAt ? new Date(inv.createdAt).toISOString().spli const marketPrice = sku?.marketPrice != null ? Number(sku.marketPrice) : null; const condition = sku?.condition || 'Near Mint'; -const gain = (purchasePrice != null && marketPrice != null) ? marketPrice - purchasePrice : null; +const gain = + purchasePrice != null && marketPrice != null + ? marketPrice - purchasePrice + : null; + +const gainPercent = + purchasePrice != null && + marketPrice != null && + purchasePrice > 0 + ? ((marketPrice - purchasePrice) / purchasePrice) * 100 + : null; // ── Price history for this SKU's condition only ────────────────────────── const priceHistoryForChart = (sku?.history ?? []) @@ -132,40 +142,105 @@ const altSearchUrl = (card: any) => {
- -
-
-
Quantity
-

{quantity}

-
-
-
Purchase Price
-

{purchasePrice != null ? `$${purchasePrice.toFixed(2)}` : '—'}

-
-
-
Condition
-

{condition}

-
-
-
Market Price
-

{marketPrice != null ? `$${marketPrice.toFixed(2)}` : '—'}

-
-
= 0 ? 'alert-success' : 'alert-danger'}`}> -
Gain / Loss
-

{gain == null ? '—' : `${gain >= 0 ? '+' : '−'}$${Math.abs(gain).toFixed(2)}`}

-
-
+ +
+ +
+ +
+ + - -
- - - - - + + + + + + + + + + + +
+

Purchased: {inv.createdAt ? new Date(inv.createdAt).toLocaleDateString() : '—'}

+
+
+

Purchase Price

+
{purchasePrice != null ? `$${purchasePrice.toFixed(2)}` : '—'}
+
+
+

Market Price

+
{marketPrice != null ? `$${marketPrice.toFixed(2)}` : '—'}
+
+
+
+
= 0 ? 'alert-success' : 'alert-danger'}`}> +

Gain / Loss ($)

+
{gain == null ? '—' : `${gain >= 0 ? '+' : '−'}$${Math.abs(gain).toFixed(2)}`}
+
+
= 0 ? 'alert-success' : 'alert-danger'}`}> +

Gain / Loss (%)

+
+ { + gainPercent == null + ? '—' + : `${gainPercent >= 0 ? '+' : '−'}${Math.abs(gainPercent).toFixed(2)}%` + } +
+
+
+
+ + +
+ + + + + + -
-
{ {catalogs.map(name => )} -
-
- + + -
-
- - -
+ +
- + +
-
+
Market Price History ({condition})
@@ -232,10 +304,14 @@ const altSearchUrl = (card: any) => {
-
+
TCGPlayer +
+ + +
@@ -243,4 +319,4 @@ const altSearchUrl = (card: any) => {
-)} +)} \ No newline at end of file