47 lines
1.6 KiB
Markdown
47 lines
1.6 KiB
Markdown
|
|
---
|
||
|
|
convoy: pricing-online-local
|
||
|
|
brief_number: 7
|
||
|
|
depends_on: [2, 6]
|
||
|
|
recommended_model: composer-2.5
|
||
|
|
model_tier: standard
|
||
|
|
files:
|
||
|
|
- pages/api/cards/owned.js
|
||
|
|
- pages/api/collections/[identifier]/cards.js
|
||
|
|
- lib/use-collection-view.js
|
||
|
|
- components/CollectionPageView.js
|
||
|
|
- pages/my-cards.js
|
||
|
|
- test/api/cards-owned-sort.test.js
|
||
|
|
---
|
||
|
|
|
||
|
|
# Brief 7: Sort by price wiring
|
||
|
|
|
||
|
|
## Goal (1 sentence)
|
||
|
|
|
||
|
|
Wire “Sort by Price” through owned-cards and list APIs into collection and My Collection UIs.
|
||
|
|
|
||
|
|
## Files in scope (do not edit anything else)
|
||
|
|
- `pages/api/cards/owned.js`
|
||
|
|
- `pages/api/collections/[identifier]/cards.js`
|
||
|
|
- `lib/use-collection-view.js`
|
||
|
|
- `components/CollectionPageView.js`
|
||
|
|
- `pages/my-cards.js`
|
||
|
|
- `test/api/cards-owned-sort.test.js`
|
||
|
|
|
||
|
|
## Conventions to follow
|
||
|
|
- Query params: `sort=name|price|rarity|date`, `order=asc|desc` (default `name`/`asc`).
|
||
|
|
- Price sort uses `listUnitPriceExpr` or `COALESCE(c.current_price, c.market_price)`; NULLs last.
|
||
|
|
- `CollectionPageView` select options must use stable values (`name`, `price`, etc.) not display strings.
|
||
|
|
- Server-side sort required for paginated My Collection.
|
||
|
|
|
||
|
|
## Acceptance criteria
|
||
|
|
- [ ] `/api/cards/owned?sort=price&order=desc` orders by effective price
|
||
|
|
- [ ] Collection cards API supports same params
|
||
|
|
- [ ] UI sort dropdown changes card order
|
||
|
|
- [ ] API test asserts ORDER BY clause or result ordering
|
||
|
|
- [ ] Tests pass
|
||
|
|
- [ ] No scope expansion
|
||
|
|
|
||
|
|
## Rationale (≤3 sentences)
|
||
|
|
|
||
|
|
Sort UI exists but is inert. Server-side sort avoids loading entire collections client-side. Depends on valuation helpers for consistent price column.
|