Created
January 5, 2022 06:29
-
-
Save kgravenreuth/d14ef2819bd4c39b5b9d5e0d94b95764 to your computer and use it in GitHub Desktop.
Cloudbet Market Helper - Render Single View for Game Lines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const [ headers, home, away ] = React.useMemo(() => { | |
const headers = ['Competitor']; | |
const home = [homeName]; | |
const away = [awayName]; | |
if(sportMarketsGameLine[sportKey]){ | |
sportMarketsGameLine[sportKey].forEach(market => { | |
const [current, err] = getMarket(event, market); | |
if(!err && current[0]){ | |
headers.push(current[0].name); | |
const { variables: { handicap: handicapHome, total: totalHome }, back: { price: priceHome } } = current[0].lines[0][0]; | |
const { variables: { handicap: handicapAway, total: totalAway }, back: { price: priceAway } } = current[0].lines[0][0]; | |
home.push({ name: handicapHome || totalHome, price: priceHome }); | |
away.push({ name: handicapAway || totalAway, price: priceAway }); | |
} | |
}) | |
} | |
return [ headers, home, away ]; | |
}, [event, sportKey, homeName, awayName]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment