moved code to components for grid/cards added stickyfilter.astro
This commit is contained in:
@@ -1,61 +1,17 @@
|
||||
---
|
||||
import Layout from '../layouts/Main.astro';
|
||||
import RarityIcon from "../components/RarityIcon.astro";
|
||||
|
||||
//import { eq } from 'drizzle-orm';
|
||||
import { db } from '../db';
|
||||
//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" },
|
||||
limit: 320,
|
||||
with: {
|
||||
prices: true,
|
||||
}
|
||||
});
|
||||
|
||||
const order = ["Near Mint", "Lightly Played", "Moderately Played", "Heavily Played", "Damaged"];
|
||||
import CardGrid from "../components/CardGrid.astro";
|
||||
import Card from "../components/Card.astro";
|
||||
import StickyFilter from '../components/StickyFilter.astro';
|
||||
---
|
||||
|
||||
<Layout>
|
||||
<StickyFilter />
|
||||
<div class="container">
|
||||
<h1 class="my-5">Rigid's app thing</h1>
|
||||
<div class="row">
|
||||
<div class="col-sm-12 col-md-3">
|
||||
<div class="h5">Inventory management placeholder</div>
|
||||
</div>
|
||||
<div class="col-sm-12 col-md-9">
|
||||
<div class="row g-4 row-cols-1 row-cols-md-2 row-cols-lg-3 row-cols-xl-4">
|
||||
{pokemon.map((card) => (
|
||||
<div class="col">
|
||||
<img src={`/cards/${card.productId}.jpg`} alt={card.productName} class="w-100 img-fluid rounded-4 mb-2" />
|
||||
<div class="col-auto h6 my-0">{card.productName}</div>
|
||||
<div class="d-flex justify-content-between">
|
||||
<div class="copy-small">{card.number}</div>
|
||||
<RarityIcon rarity={card.rarityName} />
|
||||
</div>
|
||||
<div class="row row-cols-5 gx-1 mt-1">
|
||||
{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) => (
|
||||
<div class="col p price-label">
|
||||
{price.condition.split(' ').map((w) => w[0]).join('')}
|
||||
<br />${price.marketPrice}
|
||||
</div>
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
))}
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<CardGrid>
|
||||
<Card slot="Card"></Card>
|
||||
</CardGrid>
|
||||
</div>
|
||||
</Layout>
|
||||
</div>
|
||||
</Layout>
|
||||
Reference in New Issue
Block a user