Skip to content

Commit

Permalink
unique markets
Browse files Browse the repository at this point in the history
  • Loading branch information
CleanBread committed Nov 18, 2024
1 parent e4ee05d commit a5e4dc4
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/compositions/events/Game/Game.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { OpponentLogo } from 'components/dataDisplay'
import { Href } from 'components/navigation'
import { LiveLabel } from 'components/ui'
import Markets, { MarketsSkeleton } from 'compositions/events/Markets/Markets'
import UniqueMarkets from 'compositions/events/UniqueMarkets/UniqueMarkets'


export const GameSkeleton: React.FC<{ className?: string }> = ({ className }) => {
Expand Down Expand Up @@ -69,6 +70,7 @@ const Game: React.FC<GameProps> = ({ className, leagueUrl, game, withTopRadius,
})

const isInLive = status === GameStatus.Live
const MarketsComp = isUnique ? UniqueMarkets : Markets

const rootClassName = cx(
'group flex mb:flex-col ds:items-center justify-between',
Expand Down Expand Up @@ -123,7 +125,7 @@ const Game: React.FC<GameProps> = ({ className, leagueUrl, game, withTopRadius,
<div className="w-full ds:max-w-[26.25rem] mb:mt-2">
{
isMarketsVisible ? (
<Markets gameId={gameId} gameStatus={status} />
<MarketsComp gameId={gameId} gameStatus={status} />
) : (
<MarketsSkeleton />
)
Expand Down
39 changes: 39 additions & 0 deletions src/compositions/events/UniqueMarkets/UniqueMarkets.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
'use client'

import React from 'react'
import { GameStatus } from '@azuro-org/toolkit'
import { useActiveMarkets } from '@azuro-org/sdk'

import { MarketsSkeleton } from 'compositions/events/Markets/Markets'
import Market from 'compositions/events/Markets/components/Market/Market'


type UniqueMarketsProps = {
gameId: string
gameStatus: GameStatus
}


const UniqueMarkets: React.FC<UniqueMarketsProps> = ({ gameId, gameStatus }) => {
const { markets, loading } = useActiveMarkets({ gameId, gameStatus, livePollInterval: 30_000 })


if (loading || gameStatus === GameStatus.Live && !markets?.length) {
return <MarketsSkeleton />
}

return (
<div className="w-full">
{
markets.map(market => (
<Market
key={market.marketKey}
market={market}
/>
))
}
</div>
)
}

export default UniqueMarkets

0 comments on commit a5e4dc4

Please sign in to comment.