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)} € - ))}