Match Card Adapter (Mr. Doge SDK)
mrdoge-ui/mrdoge-match-card-adapterFreeUtility
Maps a real matches.get()/odds.list() response onto Match Card's props.
Install it
npx shadcn@latest add https://mrdoge.co/r/mrdoge-match-card-adapter.jsonSource
1import type { MatchDetail, Market } from "@mrdoge/protocol"2import type {3 MatchCardDataProps,4 MatchCardOdds,5 MatchCardStatus,6} from "@/registry/mrdoge-ui/match-card/match-card"7import type { OddsOption, OddsMovement } from "@/registry/mrdoge-ui/odds-selector/odds-selector"89// match.status (upcoming/live/completed) is the authoritative field, always10// kept fresh by the server. Clock.state is finer (adds paused/intermission/11// interrupted) but comes from the live-stats feed, which can stop updating12// once a match ends, e.g. frozen on "live" at "90+5'" instead of ever13// transitioning to "finished". So match.status decides the coarse bucket14// first; clock.state only refines *within* "live".15function toMatchCardStatus(match: MatchDetail): MatchCardStatus {16 if (match.status === "upcoming") return "scheduled"17 if (match.status === "completed") return "finished"18 return match.stats?.clock?.state ?? "live"19}2021// Outcome order (1/X/2 left-to-right, Over before Under, ...) is decided22// server-side: the SDK gateway orders every market's lines before they23// ever reach here, so there's nothing to sort in this adapter.24//25// Odds Selector's own examples have room for real team names; Match26// Card is a lot narrower, so it asks for "code" instead (1/X/2), short27// and never needs truncating.28export function toOddsOptions(29 market?: Market,30 {31 labelFrom = "caption",32 movementById,33 }: {34 labelFrom?: "caption" | "code"35 /** From useOddsMovement(market): id -> "up" | "down" since the previous snapshot. */36 movementById?: Record<string, OddsMovement>37 } = {}38): OddsOption[] {39 if (!market) return []40 return market.lines.map((line) => ({41 id: line.id,42 label: labelFrom === "code" ? line.code : (line.caption ?? line.code),43 price: line.price.toFixed(2),44 suspended: !line.isAvailable,45 movement: movementById?.[line.id],46 }))47}4849function toMatchCardOdds(50 market?: Market,51 movementById?: Record<string, OddsMovement>52): MatchCardOdds | undefined {53 if (!market) return undefined54 return {55 market: market.displayName,56 options: toOddsOptions(market, { labelFrom: "code", movementById }),57 }58}5960// Public, unauthenticated, cached CDN. Not part of the Team shape itself.61// See /docs/reference/images.62export function teamLogoUrl(teamId: number) {63 return `https://api.mrdoge.co/images/teams/${teamId}.png`64}6566/**67 * Maps a real `matches.get()` / `matches.subscribe()` response (plus an68// … truncated
What it pulls in
npm packages
Other registry items
Files it writes
More from mrdoge-ui
All 26 items| Component | Registry | Kind | Access | Installs | Command |
|---|---|---|---|---|---|
| Bet Slip Adapter (Mr. Doge SDK)mrdoge-bet-slip-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Mr. Doge Clientmrdoge-client | mrdoge-ui | Utilities | Free | 1 dep | |
| Conflict Adapter (Mr. Doge SDK)mrdoge-conflict-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Match Highlight Adapter (Mr. Doge SDK)mrdoge-match-highlight-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Match Timeline Adapter (Mr. Doge SDK)mrdoge-match-timeline-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Odds Selector Adapter (Mr. Doge SDK)mrdoge-odds-selector-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Stats List Adapter (Mr. Doge SDK)mrdoge-stats-list-adapter | mrdoge-ui | Utilities | Free | 1 dep | |
| Rate Limitrate-limit | mrdoge-ui | Utilities | Free | no deps |
