Skip to content

Commit

Permalink
Merge branch 'dev' of github.com:thales-markets/thales-sport-markets …
Browse files Browse the repository at this point in the history
…into dev
  • Loading branch information
vladanthales committed Mar 7, 2023
2 parents ffdb692 + a2e5795 commit cd7a37a
Show file tree
Hide file tree
Showing 114 changed files with 295 additions and 87 deletions.
Binary file added public/logos/Tennis/Husler.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/adrian-mannarino.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/albert-ramos-vinolas.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/alex-de-minaur.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/alex-molcan.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/alexander-bublik.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/alexander-zverev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/alexei-popyrin.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/andrey-rublev.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/andy-murray.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/arthur-rinderknech.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/atp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/ben-shelton.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/benjamin-bonzi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/bernabe-zapata-miralles.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/borna-coric.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/botic-van-de-zandschulp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/brandon-nakashima.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/cameron-norrie.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/carlos-alcaraz.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/casper-ruud.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/christopher-o'connell.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/constant-lestienne.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/corentin-moutet.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/logos/Tennis/cristian-garin.png
Binary file added public/logos/Tennis/daniel-altmaier.png
Binary file added public/logos/Tennis/daniel-elahi-galan.png
Binary file added public/logos/Tennis/daniel-evans.png
Binary file added public/logos/Tennis/daniil-medvedev.png
Binary file added public/logos/Tennis/david-goffin.png
Binary file added public/logos/Tennis/denis-kudla.png
Binary file added public/logos/Tennis/denis-shapovalov.png
Binary file added public/logos/Tennis/diego-schwartzman.png
Binary file added public/logos/Tennis/dominic-thiem.png
Binary file added public/logos/Tennis/dusan-lajovic.png
Binary file added public/logos/Tennis/emil-ruusuvuori.png
Binary file added public/logos/Tennis/emilio-gomez.png
Binary file added public/logos/Tennis/fabio-fognini.png
Binary file added public/logos/Tennis/facundo-bagnis.png
Binary file added public/logos/Tennis/federico-coria.png
Binary file added public/logos/Tennis/felix-auger-aliassime.png
Binary file added public/logos/Tennis/filip-krajinovic.png
Binary file added public/logos/Tennis/frances-tiafoe.png
Binary file added public/logos/Tennis/francisco-cerundolo.png
Binary file added public/logos/Tennis/gregoire-barrere.png
Binary file added public/logos/Tennis/grigor-dimitrov.png
Binary file added public/logos/Tennis/holger-rune.png
Binary file added public/logos/Tennis/hubert-hurkacz.png
Binary file added public/logos/Tennis/hugo-dellien.png
Binary file added public/logos/Tennis/ilya-ivashka.png
Binary file added public/logos/Tennis/j.-j.-wolf.png
Binary file added public/logos/Tennis/jack-draper.png
Binary file added public/logos/Tennis/jannik-sinner.png
Binary file added public/logos/Tennis/jason-kubler.png
Binary file added public/logos/Tennis/jaume-munar.png
Binary file added public/logos/Tennis/jenson-brooksby.png
Binary file added public/logos/Tennis/jiri-lehecka.png
Binary file added public/logos/Tennis/john-isner.png
Binary file added public/logos/Tennis/jordan-thompson.png
Binary file added public/logos/Tennis/juan-pablo-varillas.png
Binary file added public/logos/Tennis/karen-khachanov.png
Binary file added public/logos/Tennis/laslo-djere.png
Binary file added public/logos/Tennis/lorenzo-musetti.png
Binary file added public/logos/Tennis/lorenzo-sonego.png
Binary file added public/logos/Tennis/mackenzie-mcDonald.png
Binary file added public/logos/Tennis/marco-cecchinato.png
Binary file added public/logos/Tennis/marcos-giron.png
Binary file added public/logos/Tennis/marin-cilic.png
Binary file added public/logos/Tennis/marton-fucsovics.png
Binary file added public/logos/Tennis/matteo-berrettini.png
Binary file added public/logos/Tennis/maxime-cressy.png
Binary file added public/logos/Tennis/michael-mmoh.png
Binary file added public/logos/Tennis/mikael-ymer.png
Binary file added public/logos/Tennis/miomir-kecmanovic.png
Binary file added public/logos/Tennis/nick-kyrgios.png
Binary file added public/logos/Tennis/nicolas-jarry.png
Binary file added public/logos/Tennis/novak-djokovic.png
Binary file added public/logos/Tennis/nuno-borges.png
Binary file added public/logos/Tennis/oscar-otte.png
Binary file added public/logos/Tennis/pablo-carreno-busta.png
Binary file added public/logos/Tennis/pedro-cachin.png
Binary file added public/logos/Tennis/quentin-halys.png
Binary file added public/logos/Tennis/rafael-nadal.png
Binary file added public/logos/Tennis/richard-gasquet.png
Binary file added public/logos/Tennis/roberto-bautista-agut.png
Binary file added public/logos/Tennis/roberto-carballes-baena.png
Binary file added public/logos/Tennis/sebastian-baez.png
Binary file added public/logos/Tennis/sebastian-korda.png
Binary file added public/logos/Tennis/soonwoo-kwon.png
Binary file added public/logos/Tennis/stan-wawrinka.png
Binary file added public/logos/Tennis/stefanos-tsitsipas.png
Binary file added public/logos/Tennis/tallon-griekspoor.png
Binary file added public/logos/Tennis/taylor-fritz.png
Binary file added public/logos/Tennis/thiago-monteiro.png
Binary file added public/logos/Tennis/tomas-martin-etcheverry.png
Binary file added public/logos/Tennis/tommy-paul.png
Binary file added public/logos/Tennis/ugo-humbert.png
Binary file added public/logos/Tennis/yibing-wu.png
Binary file added public/logos/Tennis/yoshihito-nishioka.png
Binary file added public/logos/Tennis/zhizhen-zhang.png
Binary file modified src/assets/fonts/LeagueIcons/LeagueIcons.ttf
Binary file not shown.
3 changes: 2 additions & 1 deletion src/constants/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export enum SportFilterEnum {
Baseball = 'Baseball',
Hockey = 'Hockey',
UFC = 'UFC',
Motosport = 'Motosport',
Tennis = 'Tennis',
// Motosport = 'Motosport',
}

export const COLLATERALS = [
Expand Down
6 changes: 6 additions & 0 deletions src/constants/queryKeys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,12 @@ export const QUERY_KEYS = {
ParlayAmmData: (networkId: NetworkId) => ['parlayAmmData', networkId],
Market: (marketAddress: string, networkId: NetworkId) => ['market', marketAddress, networkId],
LiveResult: (marketId: string) => ['liveResult', marketId],
EnetpulseLiveResult: (marketId: string, gameDate: string, sportTag: number) => [
'enetpulseLiveResult',
marketId,
gameDate,
sportTag,
],
ChildMarkets: (marketAddress: string, networkId: NetworkId) => ['childMarkets', marketAddress, networkId],
PositionDetails: (
marketAddress: string,
Expand Down
46 changes: 44 additions & 2 deletions src/constants/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,24 @@ export const TAGS_LIST: Tags = [
hidden: false,
priority: 702,
},
{
id: 9153,
label: 'Tennis',
logo: `/logos/Tennis/atp.png`,
logoClass: 'icon-league league--atp',
favourite: false,
hidden: false,
priority: 602,
},
{
id: 9156,
label: 'Tennis',
logo: `/logos/Tennis/atp.png`,
logoClass: 'icon-league league--atp',
favourite: false,
hidden: false,
priority: 603,
},
];

export const SPORTS_MAP: SportsMap = {
Expand All @@ -195,9 +213,24 @@ export const SPORTS_MAP: SportsMap = {
9019: 'Soccer',
9100: 'Motosport',
9101: 'Motosport',
9153: 'Tennis',
9156: 'Tennis',
};

export const TAGS_OF_MARKETS_WITHOUT_DRAW_ODDS = [9001, 9002, 9003, 9004, 9005, 9006, 9008, 9007, 9100, 9101];
export const TAGS_OF_MARKETS_WITHOUT_DRAW_ODDS = [
9001,
9002,
9003,
9004,
9005,
9006,
9008,
9007,
9100,
9101,
9153,
9156,
];

export const SPORTS_TAGS_MAP: SportsTagsMap = {
Football: [9001, 9002],
Expand All @@ -207,6 +240,7 @@ export const SPORTS_TAGS_MAP: SportsTagsMap = {
Soccer: [9010, 9011, 9012, 9013, 9014, 9015, 9016, 9017, 9018, 9019],
UFC: [9007],
Motosport: [9100, 9101],
Tennis: [9153, 9156],
};

export enum TAGS_FLAGS {
Expand All @@ -231,10 +265,12 @@ export enum TAGS_FLAGS {
MOTOGP = 9101,
}

export const ENETPULSE_SPORTS = [9153, 9156];

export const MLS_TAG = 9010;
export const FIFA_WC_TAG = 9018;

export const PERSON_COMPETITIONS = [9007, 9100, 9101];
export const PERSON_COMPETITIONS = [9007, 9100, 9101, 9153, 9156];

export enum BetType {
WINNER = 0,
Expand Down Expand Up @@ -277,6 +313,8 @@ export const SCORING_MAP: SportsMap = {
9019: 'goals',
9100: '',
9101: '',
9153: 'gems',
9156: 'gems',
};

export const MATCH_RESOLVE_MAP: SportsMap = {
Expand All @@ -300,6 +338,8 @@ export const MATCH_RESOLVE_MAP: SportsMap = {
9019: 'regular',
9100: '',
9101: '',
9153: '',
9156: '',
};

export const SPORT_PERIODS_MAP: SportsMap = {
Expand All @@ -321,4 +361,6 @@ export const SPORT_PERIODS_MAP: SportsMap = {
9017: 'half',
9018: 'half',
9019: 'half',
9153: 'set',
9156: 'set',
};
47 changes: 35 additions & 12 deletions src/pages/Markets/Home/MarketListCard/MarketListCard.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import SPAAnchor from 'components/SPAAnchor';
import TimeRemaining from 'components/TimeRemaining';
import Tooltip from 'components/Tooltip';
import { BetType } from 'constants/tags';
import { BetType, ENETPULSE_SPORTS } from 'constants/tags';
import { t } from 'i18next';
import useEnetpulseSportMarketLiveResultQuery from 'queries/markets/useEnetpulseSportMarketLiveResultQuery';
import useSportMarketLiveResultQuery from 'queries/markets/useSportMarketLiveResultQuery';
import React, { useEffect, useState } from 'react';
import { useSelector } from 'react-redux';
Expand All @@ -19,24 +20,24 @@ import Odds from './components/Odds';
import {
Arrow,
ClubLogo,
MainContainer,
MatchInfoConatiner,
MatchTimeLabel,
MainContainer,
SecondRowContainer,
OddsWrapper,
Result,
ResultLabel,
ResultWrapper,
SecondRowContainer,
TeamLogosConatiner,
TeamNameLabel,
TeamNamesConatiner,
TeamsInfoConatiner,
VSLabel,
Wrapper,
TotalMarketsContainer,
TotalMarketsLabel,
TotalMarkets,
TotalMarketsArrow,
TotalMarketsContainer,
TotalMarketsLabel,
VSLabel,
Wrapper,
} from './styled-components';

// 3 for double chance, 1 for spread, 1 for total
Expand Down Expand Up @@ -68,7 +69,9 @@ const MarketListCard: React.FC<MarketRowCardProps> = ({ market, language }) => {
const isGameRegularlyResolved = market.isResolved && !market.isCanceled;
const isPendingResolution = isGameStarted && !isGameResolved;
const showOdds = !isPendingResolution && !isGameResolved && !market.isPaused;
const gameIdString = Web3.utils.toAscii(market.gameId);
const isEnetpulseSport = ENETPULSE_SPORTS.includes(Number(market.tags[0]));
const gameIdString = Web3.utils.hexToAscii(market.gameId);
const gameDate = new Date(market.maturityDate).toISOString().split('T')[0];

const doubleChanceMarkets = market.childMarkets.filter((market) => market.betType === BetType.DOUBLE_CHANCE);
const spreadTotalMarkets = market.childMarkets.filter((market) => market.betType !== BetType.DOUBLE_CHANCE);
Expand All @@ -78,14 +81,30 @@ const MarketListCard: React.FC<MarketRowCardProps> = ({ market, language }) => {
const showSecondRowOnMobile = isMobile && hasChildMarkets;

const useLiveResultQuery = useSportMarketLiveResultQuery(gameIdString, {
enabled: isAppReady && isPendingResolution,
enabled: isAppReady && isPendingResolution && !isEnetpulseSport,
});

const useEnetpulseLiveResultQuery = useEnetpulseSportMarketLiveResultQuery(gameIdString, gameDate, market.tags[0], {
enabled: isAppReady && isEnetpulseSport,
});

useEffect(() => {
if (useLiveResultQuery.isSuccess && useLiveResultQuery.data) {
setLiveResultInfo(useLiveResultQuery.data);
if (isEnetpulseSport) {
if (useEnetpulseLiveResultQuery.isSuccess && useEnetpulseLiveResultQuery.data) {
setLiveResultInfo(useEnetpulseLiveResultQuery.data);
}
} else {
if (useLiveResultQuery.isSuccess && useLiveResultQuery.data) {
setLiveResultInfo(useLiveResultQuery.data);
}
}
}, [useLiveResultQuery, useLiveResultQuery.data]);
}, [
useLiveResultQuery,
useLiveResultQuery.data,
useEnetpulseLiveResultQuery,
useEnetpulseLiveResultQuery.data,
isEnetpulseSport,
]);

return (
<Wrapper isResolved={isGameRegularlyResolved}>
Expand All @@ -102,6 +121,9 @@ const MarketListCard: React.FC<MarketRowCardProps> = ({ market, language }) => {
component={
<MatchTimeLabel>
{formatShortDateWithTime(market.maturityDate)}{' '}
{isEnetpulseSport && liveResultInfo?.tournamentName
? '| ' + liveResultInfo?.tournamentName
: ''}
{isFifaWCGame(market.tags[0]) && (
<Tooltip overlay={t(`common.fifa-tooltip`)} iconFontSize={12} marginLeft={2} />
)}
Expand Down Expand Up @@ -181,6 +203,7 @@ const MarketListCard: React.FC<MarketRowCardProps> = ({ market, language }) => {
liveResultInfo={liveResultInfo}
isCanceled={market.isCanceled}
isPaused={market.isPaused}
isEnetpulseSport={isEnetpulseSport}
/>
)}
</MainContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,16 @@ type MatchStatusProps = {
isCanceled: boolean;
isPaused: boolean;
liveResultInfo: SportMarketLiveResult | undefined;
isEnetpulseSport: boolean;
};

const MatchStatus: React.FC<MatchStatusProps> = ({ isPendingResolution, isCanceled, isPaused, liveResultInfo }) => {
const MatchStatus: React.FC<MatchStatusProps> = ({
isPendingResolution,
isCanceled,
isPaused,
liveResultInfo,
isEnetpulseSport,
}) => {
const { t } = useTranslation();

const displayClockTime = liveResultInfo?.displayClock.replaceAll("'", '');
Expand All @@ -23,18 +30,23 @@ const MatchStatus: React.FC<MatchStatusProps> = ({ isPendingResolution, isCancel
<Container bottomAlign={isPendingResolution}>
{isPendingResolution ? (
<FlexDivRow>
{liveResultInfo?.status != GAME_STATUS.FINAL && liveResultInfo?.status != GAME_STATUS.FULL_TIME && (
<MatchPeriodContainer>
<MatchPeriodLabel>{`${getOrdinalNumberLabel(Number(liveResultInfo?.period))} ${t(
`markets.market-card.${SPORT_PERIODS_MAP[Number(liveResultInfo?.sportId)]}`
)}`}</MatchPeriodLabel>
<FlexDivCentered>
<MatchPeriodLabel className="red">
{displayClockTime}
<MatchPeriodLabel className="blink">&prime;</MatchPeriodLabel>
</MatchPeriodLabel>
</FlexDivCentered>
</MatchPeriodContainer>
{liveResultInfo?.status != GAME_STATUS.FINAL &&
liveResultInfo?.status != GAME_STATUS.FULL_TIME &&
!isEnetpulseSport && (
<MatchPeriodContainer>
<MatchPeriodLabel>{`${getOrdinalNumberLabel(Number(liveResultInfo?.period))} ${t(
`markets.market-card.${SPORT_PERIODS_MAP[Number(liveResultInfo?.sportId)]}`
)}`}</MatchPeriodLabel>
<FlexDivCentered>
<MatchPeriodLabel className="red">
{displayClockTime}
<MatchPeriodLabel className="blink">&prime;</MatchPeriodLabel>
</MatchPeriodLabel>
</FlexDivCentered>
</MatchPeriodContainer>
)}
{isEnetpulseSport && (
<Status color={STATUS_COLOR.STARTED}>{t('markets.market-card.pending')}</Status>
)}
<ScoreContainer>
<TeamScoreLabel>{liveResultInfo?.homeScore}</TeamScoreLabel>
Expand Down
Loading

0 comments on commit cd7a37a

Please sign in to comment.