Skip to content

✨ Add Market Categories Filter and Sorting #42

@Mosas2000

Description

@Mosas2000

Description

The market-core contract supports categories (Crypto, Sports, Politics, Economics, Other) but the frontend doesn't utilize this for filtering or display.

Contract Support

;; market-core.clar (Lines 20-26)
(define-constant CATEGORY-CRYPTO u1)
(define-constant CATEGORY-SPORTS u2)
(define-constant CATEGORY-POLITICS u3)
(define-constant CATEGORY-ECONOMICS u4)
(define-constant CATEGORY-OTHER u5)

Current Frontend

The MarketsPage only has status filters (All, Active, Resolved) but no category filters.

Proposed Features

1. Category Filter Tabs

[All] [🪙 Crypto] [⚽ Sports] [🏛️ Politics] [📈 Economics] [📦 Other]

2. Category Badge on MarketCard

Show the category with an icon on each market card.

3. Sorting Options

  • Newest first (current default)
  • Largest pool
  • Ending soon
  • Most participants

4. Combined Filters

Allow both category AND status filtering:

Category: [Crypto ▾]  Status: [Active ▾]  Sort: [Ending Soon ▾]

UI Mockup

┌─ Markets ────────────────────────────────┐
│ [All] [🪙 Crypto] [⚽ Sports] [🏛️ Politics]│
│                                          │
│ Status: [All ▾]    Sort: [Newest ▾]      │
│                                          │
│ ┌─────────────────────────────────────┐  │
│ │ 🪙 Crypto                           │  │
│ │ Will BTC reach $100k by Dec 2026?   │  │
│ │ Pool: 245 STX    Ends: 3 days       │  │
│ └─────────────────────────────────────┘  │
└──────────────────────────────────────────┘

Files to Modify

  • frontend/src/types/market.ts - Add category to Market type
  • frontend/src/utils/helpers.ts - Add category parsing
  • frontend/src/pages/MarketsPage.tsx - Add filter UI
  • frontend/src/components/MarketCard.tsx - Show category badge

Priority

🟢 Low - UX enhancement

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions