From 9d3261718fb6424a7a37f49bb7e1e19dc3874e3f Mon Sep 17 00:00:00 2001 From: nlevesque Date: Wed, 29 Jul 2026 00:07:53 +0200 Subject: [PATCH] =?UTF-8?q?Remove=20quantity=20field;=20normalize=20missin?= =?UTF-8?q?g=20prices=20to=200,00=20=E2=82=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Each collection row is a unique card (own condition/notes), so quantity was noise: dropped the field in Directus and removed it from the add dialog, collection/grid/table views, dashboard stats and sort options. Cards without Cardmarket data now consistently show 0,00 € (base price row is always displayed on the card page). --- src/lib/collection-filter.ts | 3 --- src/lib/collection.ts | 8 ++++---- src/lib/directus.ts | 1 - src/pages/api/collection.ts | 2 -- src/pages/card/[id].astro | 26 ++++---------------------- src/pages/friends/[username].astro | 10 +--------- src/pages/index.astro | 4 ++-- src/pages/mycards.astro | 24 +----------------------- 8 files changed, 12 insertions(+), 66 deletions(-) diff --git a/src/lib/collection-filter.ts b/src/lib/collection-filter.ts index 11d5c4c..dbe98f9 100644 --- a/src/lib/collection-filter.ts +++ b/src/lib/collection-filter.ts @@ -67,9 +67,6 @@ export function initCollectionFilter() { case "total-desc": return (a: HTMLElement, b: HTMLElement) => num(b, "total") - num(a, "total"); - case "qty-desc": - return (a: HTMLElement, b: HTMLElement) => - num(b, "qty") - num(a, "qty"); default: // "Ajout récent" — original server-rendered order return (a: HTMLElement, b: HTMLElement) => diff --git a/src/lib/collection.ts b/src/lib/collection.ts index f045005..caa6bbf 100644 --- a/src/lib/collection.ts +++ b/src/lib/collection.ts @@ -20,9 +20,10 @@ export const variantPriceMap: Record = { }; /** - * Resolve the Cardmarket unit price and line total for each collection card. + * Resolve the Cardmarket unit price for each collection card. * Card details come from the 24h in-memory cache, so repeated cards and - * repeated page loads don't hit the TCGdex API again. + * repeated page loads don't hit the TCGdex API again. Cards without a + * Cardmarket price get 0 for consistent display (0,00 €). */ export async function priceCollectionCards( cards: MyCard[], @@ -36,8 +37,7 @@ export async function priceCollectionCards( const priceKey = variantPriceMap[card.variant ?? ""] ?? "avg"; price = cardmarket[priceKey] ?? cardmarket.avg ?? 0; } - const quantity = card.quantity ?? 1; - return { ...card, price, totalPrice: price * quantity }; + return { ...card, price, totalPrice: price }; }), ); } diff --git a/src/lib/directus.ts b/src/lib/directus.ts index fc21d8e..da5d924 100644 --- a/src/lib/directus.ts +++ b/src/lib/directus.ts @@ -32,7 +32,6 @@ export interface MyCard { card_name: string; card_image: string | null; variant: string | null; - quantity: number | null; condition: string | null; notes: string | null; set_name: string | null; diff --git a/src/pages/api/collection.ts b/src/pages/api/collection.ts index 2d3e392..b08d43d 100644 --- a/src/pages/api/collection.ts +++ b/src/pages/api/collection.ts @@ -15,7 +15,6 @@ export const POST: APIRoute = async ({ request, locals }) => { card_name, card_image, variant, - quantity, condition, notes, set_name, @@ -36,7 +35,6 @@ export const POST: APIRoute = async ({ request, locals }) => { card_name, card_image: card_image || null, variant: variant || "Base", - quantity: Number(quantity) || 1, condition: condition || null, notes: notes || null, set_name: set_name || null, diff --git a/src/pages/card/[id].astro b/src/pages/card/[id].astro index c1a305b..df3f91a 100644 --- a/src/pages/card/[id].astro +++ b/src/pages/card/[id].astro @@ -53,19 +53,15 @@ const availableVariants = card.variants const variantPrices: { label: string; price: number }[] = []; -// Always include the base avg price (no variant suffix) -if (cardmarket?.avg != null) { - variantPrices.push({ label: "Base", price: cardmarket.avg }); -} +// Always include the base avg price (0 when no Cardmarket data) +variantPrices.push({ label: "Base", price: cardmarket?.avg ?? 0 }); // Add prices for each available variant for (const variant of availableVariants) { if (variant === "normal") continue; // normal uses the base avg, already added const priceKey = variantPriceMap[variant]; - const price = cardmarket?.[priceKey]; - if (price != null) { - variantPrices.push({ label: variantLabels[variant] ?? variant, price }); - } + const price = cardmarket?.[priceKey] ?? 0; + variantPrices.push({ label: variantLabels[variant] ?? variant, price }); } // Determine which tabs have content @@ -527,19 +523,6 @@ const primaryColor = getPrimaryColor(typeNames); -
- - -
-
{card.condition && ( @@ -291,11 +283,6 @@ const distinctConditions = [ {card.price.toFixed(2)} € - {card.quantity > 1 && ( - - = {card.totalPrice.toFixed(2)} € - - )} @@ -327,9 +314,7 @@ const distinctConditions = [ Set Variant État - Qté Prix - Total @@ -341,7 +326,6 @@ const distinctConditions = [ data-condition={card.condition} data-price={card.price} data-total={card.totalPrice} - data-qty={card.quantity} > @@ -379,15 +363,9 @@ const distinctConditions = [ {card.condition} )} - - ×{card.quantity} - {card.price.toFixed(2)} € - - {card.totalPrice.toFixed(2)} € - ))}