From a7cd68282788947f6fbdaf4d35de158d73993a1c Mon Sep 17 00:00:00 2001 From: zach Date: Tue, 17 Feb 2026 13:07:29 -0500 Subject: [PATCH] adding files --- src/components/Card.astro | 58 +++++++++++++++++++++++++++++ src/components/CardGrid.astro | 10 +++++ src/components/StickyFilter.astro | 11 ++++++ src/pages/api/cards.ts | 18 +++++++++ src/svg/bg.svg | 1 + src/svg/rarity/black_white_rare.svg | 5 +++ src/svg/rarity/double_rare_jp.svg | 4 ++ src/svg/rarity/rare_secret.svg | 10 +++++ src/svg/rarity/rare_shining.svg | 12 ++++++ 9 files changed, 129 insertions(+) create mode 100644 src/components/Card.astro create mode 100644 src/components/CardGrid.astro create mode 100644 src/components/StickyFilter.astro create mode 100644 src/pages/api/cards.ts create mode 100644 src/svg/bg.svg create mode 100644 src/svg/rarity/black_white_rare.svg create mode 100644 src/svg/rarity/double_rare_jp.svg create mode 100644 src/svg/rarity/rare_secret.svg create mode 100644 src/svg/rarity/rare_shining.svg diff --git a/src/components/Card.astro b/src/components/Card.astro new file mode 100644 index 0000000..7ec40ae --- /dev/null +++ b/src/components/Card.astro @@ -0,0 +1,58 @@ +--- +//import { eq } from 'drizzle-orm'; +import { isConditionalExpression } from 'typescript'; +import { db } from '../db'; +import RarityIcon from './RarityIcon.astro'; +//import * as schema from '../db/schema.ts'; + +// Get some sample Pokemon data from the database +//const pokemon = await db.select().from(schema.cards).where(eq(schema.cards.productLineName, "pokemon")).limit(256); +const pokemon = await db.query.cards.findMany({ + where: { productLineName: "pokemon", }, + orderBy: (cards, { desc }) => [desc(cards.marketPrice)], + limit: 320, + with: { + prices: true, + set: true, + } +}); + + +const formatPrice = (price:any) => { + if (price === null) { + return "–"; + } + price = Number(price); + if (price >= 99.99) { + return `${Math.round(price)}`; + } + return `${price.toFixed(2)}`; +}; + +const order = ["Near Mint", "Lightly Played", "Moderately Played", "Heavily Played", "Damaged"]; +--- +{pokemon.map((card) => ( +
+ {card.productName} +
{card.productName}
+
+
{card.number}
+ +
+
{card.set?.setName}
+
+ {card.prices + .slice() + .sort((a, b) => order.indexOf(a.condition) - order.indexOf(b.condition)) + .filter((price, index, arr) => + arr.findIndex(p => p.condition === price.condition) === index + ) + .map((price) => ( +
+ {price.condition.split(' ').map((w) => w[0]).join('')} +
${formatPrice(price.marketPrice)} +
+ ))} +
+
+))} \ No newline at end of file diff --git a/src/components/CardGrid.astro b/src/components/CardGrid.astro new file mode 100644 index 0000000..93d37ed --- /dev/null +++ b/src/components/CardGrid.astro @@ -0,0 +1,10 @@ +
+
+
Inventory management placeholder
+
+
+
+ +
+
+
\ No newline at end of file diff --git a/src/components/StickyFilter.astro b/src/components/StickyFilter.astro new file mode 100644 index 0000000..8f287ef --- /dev/null +++ b/src/components/StickyFilter.astro @@ -0,0 +1,11 @@ +--- +import '/src/assets/css/main.scss'; +--- + +
+
+
+
Placeholder for search input/filters
+
+
+
\ No newline at end of file diff --git a/src/pages/api/cards.ts b/src/pages/api/cards.ts new file mode 100644 index 0000000..be12dfc --- /dev/null +++ b/src/pages/api/cards.ts @@ -0,0 +1,18 @@ +import type { APIRoute } from "astro"; +import { db } from "../../db"; + +export const GET: APIRoute = async ({ url }) => { + const page = Number(url.searchParams.get("page") ?? 0); + const PAGE_SIZE = 256; + + const cards = await db.query.cards.findMany({ + where: { productLineName: "pokemon" }, + limit: PAGE_SIZE, + offset: page * PAGE_SIZE, + with: { prices: true } + }); + + return new Response(JSON.stringify(cards), { + headers: { "Content-Type": "application/json" }, + }); +}; diff --git a/src/svg/bg.svg b/src/svg/bg.svg new file mode 100644 index 0000000..7e120e5 --- /dev/null +++ b/src/svg/bg.svg @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/src/svg/rarity/black_white_rare.svg b/src/svg/rarity/black_white_rare.svg new file mode 100644 index 0000000..8a12f87 --- /dev/null +++ b/src/svg/rarity/black_white_rare.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/src/svg/rarity/double_rare_jp.svg b/src/svg/rarity/double_rare_jp.svg new file mode 100644 index 0000000..bae9c53 --- /dev/null +++ b/src/svg/rarity/double_rare_jp.svg @@ -0,0 +1,4 @@ + + + + diff --git a/src/svg/rarity/rare_secret.svg b/src/svg/rarity/rare_secret.svg new file mode 100644 index 0000000..aa413e8 --- /dev/null +++ b/src/svg/rarity/rare_secret.svg @@ -0,0 +1,10 @@ + + + + + + + + + + diff --git a/src/svg/rarity/rare_shining.svg b/src/svg/rarity/rare_shining.svg new file mode 100644 index 0000000..1865f22 --- /dev/null +++ b/src/svg/rarity/rare_shining.svg @@ -0,0 +1,12 @@ + + + + + + + + + + + +