Bet Slip Adapter (Mr. Doge SDK)
mrdoge-ui/mrdoge-bet-slip-adapterFreeUtility
Builds a BetSlipPick from a real match, one of its markets, and a selected line id.
Install it
npx shadcn@latest add https://mrdoge.co/r/mrdoge-bet-slip-adapter.jsonSource
1import type { MatchDetail, Market } from "@mrdoge/protocol"2import type { BetSlipPick } from "@/registry/mrdoge-ui/bet-slip/bet-slip"3import type { OddsMovement } from "@/registry/mrdoge-ui/odds-selector/odds-selector"45// Over/Under outcomes only carry a generic "O"/"U" code, no threshold in6// it. The threshold lives in the caption instead ("Over 1.5", "Under7// 1.5"), so that's what has to be parsed for conflict-checking.8function parseThreshold(caption: string | null | undefined): number | undefined {9 const match = caption?.match(/[\d.]+/)10 const value = match ? parseFloat(match[0]) : NaN11 return Number.isNaN(value) ? undefined : value12}1314// Public, unauthenticated, cached CDN. Not part of the Team shape itself.15// See /docs/reference/images.16function teamLogoUrl(teamId: number) {17 return `https://api.mrdoge.co/images/teams/${teamId}.png`18}1920/**21 * Builds a `BetSlipPick` from a real match, one of its markets, and a22 * selected line id. A pick is basically a selected odds line. Returns23 * `undefined` if `lineId` isn't found in `market.lines`; filter those out24 * when mapping several selections at once.25 *26 * `movementById` is optional. Pass `useOddsMovement(market)`'s result to27 * color the pick's price as odds change; omit it and the price renders28 * without any color change.29 */30export function toBetSlipPick(31 match: MatchDetail,32 market: Market,33 lineId: string,34 movementById?: Record<string, OddsMovement>35): BetSlipPick | undefined {36 const line = market.lines.find((l) => l.id === lineId)37 if (!line) return undefined3839 const isTotals = line.code.startsWith("O") || line.code.startsWith("U")4041 return {42 id: line.id,43 eventLabel: `${match.homeTeam.name} vs ${match.awayTeam.name}`,44 market: market.displayName,45 selection: line.caption ?? line.code,46 price: line.price,47 movement: movementById?.[line.id],48 unavailable: !line.isAvailable,49 home: { name: match.homeTeam.name, logoUrl: teamLogoUrl(match.homeTeam.id) },50 away: { name: match.awayTeam.name, logoUrl: teamLogoUrl(match.awayTeam.id) },51 kickoff: match.startTime,52 matchId: match.id,53 betType: market.betType,54 code: line.code,55 threshold: isTotals ? parseThreshold(line.caption) : undefined,56 }57}
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 |
|---|---|---|---|---|---|
| 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 Card Adapter (Mr. Doge SDK)mrdoge-match-card-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 |
