Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kgravenreuth/d14ef2819bd4c39b5b9d5e0d94b95764 to your computer and use it in GitHub Desktop.
Save kgravenreuth/d14ef2819bd4c39b5b9d5e0d94b95764 to your computer and use it in GitHub Desktop.
Cloudbet Market Helper - Render Single View for Game Lines
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