parent
faba6362e3
commit
edadb6f012
@ -0,0 +1,156 @@ |
|||||||
|
import { useEffect, useState } from 'react' |
||||||
|
|
||||||
|
import ReactGA from 'react-ga' |
||||||
|
|
||||||
|
import { updateAdsView } from 'requests' |
||||||
|
|
||||||
|
import { useToggle } from 'hooks' |
||||||
|
|
||||||
|
import { getLocalStorageItem, isMatchPage } from 'helpers' |
||||||
|
|
||||||
|
import { |
||||||
|
device, |
||||||
|
COUNTRY, |
||||||
|
} from 'config' |
||||||
|
|
||||||
|
import { useMatchPageStore } from 'features/MatchPage/store' |
||||||
|
|
||||||
|
import type { AdComponentType } from './index' |
||||||
|
|
||||||
|
import { checkVideo } from '../../helpers' |
||||||
|
import { |
||||||
|
adsViews, |
||||||
|
EventGA, |
||||||
|
ViewsType, |
||||||
|
} from '../../types' |
||||||
|
|
||||||
|
const countryCode = getLocalStorageItem(COUNTRY) |
||||||
|
|
||||||
|
export const useAd = ({ ad }: AdComponentType) => { |
||||||
|
const [isOpenAd, setIsOpenAd] = useState(true) |
||||||
|
const [isNeedToShow, setIsNeedToShow] = useState(true) |
||||||
|
const [shownTime, setShownTime] = useState(0) |
||||||
|
|
||||||
|
const { isFullscreen } = useMatchPageStore() |
||||||
|
|
||||||
|
const views = getLocalStorageItem(adsViews) as ViewsType |
||||||
|
const { |
||||||
|
duration, |
||||||
|
frequency, |
||||||
|
id, |
||||||
|
media, |
||||||
|
name, |
||||||
|
time_close, |
||||||
|
} = ad |
||||||
|
|
||||||
|
const { |
||||||
|
close, |
||||||
|
isOpen: isOpenCloseBtn, |
||||||
|
open: showCloseBtn, |
||||||
|
} = useToggle() |
||||||
|
|
||||||
|
const isNeedBanner = Number(views?.HOME) % frequency === 0 |
||||||
|
const isVideo = checkVideo(media.url) |
||||||
|
const currentAdsTime = duration - shownTime |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
if (!isFullscreen) { |
||||||
|
if (currentAdsTime === 0) { |
||||||
|
setShownTime(0) |
||||||
|
} else { |
||||||
|
const stopWatch = setInterval(() => { |
||||||
|
setShownTime((prev) => prev + 1) |
||||||
|
}, 1000) |
||||||
|
return () => clearInterval(stopWatch) |
||||||
|
} |
||||||
|
} |
||||||
|
return undefined |
||||||
|
}, [ |
||||||
|
isFullscreen, |
||||||
|
currentAdsTime, |
||||||
|
]) |
||||||
|
|
||||||
|
const handleClose = async () => { |
||||||
|
setIsOpenAd(false) |
||||||
|
isMatchPage() && setIsNeedToShow(false) |
||||||
|
sendBannerClickEvent(EventGA.CLOSE) |
||||||
|
} |
||||||
|
|
||||||
|
const sendBannerClickEvent = (event: EventGA) => { |
||||||
|
ReactGA.initialize('Advertisement') |
||||||
|
ReactGA.event({ |
||||||
|
action: event, |
||||||
|
category: 'Advertisement', |
||||||
|
label: `${name}_${countryCode ?? ''}_${device}`, |
||||||
|
value: id, |
||||||
|
}) |
||||||
|
} |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
setShownTime(0) |
||||||
|
|
||||||
|
if (isMatchPage()) { |
||||||
|
const interval = setInterval(() => { |
||||||
|
setIsNeedToShow(true) |
||||||
|
setIsOpenAd(true) |
||||||
|
}, frequency * 1000) |
||||||
|
|
||||||
|
return () => clearInterval(interval) |
||||||
|
} |
||||||
|
|
||||||
|
setIsNeedToShow(isNeedBanner) |
||||||
|
return setIsOpenAd(isNeedBanner) |
||||||
|
}, [ |
||||||
|
frequency, |
||||||
|
isNeedToShow, |
||||||
|
views?.HOME, |
||||||
|
isNeedBanner, |
||||||
|
]) |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
if (isFullscreen || !isOpenAd) return undefined |
||||||
|
|
||||||
|
const timeoutCloseAd = setTimeout(handleClose, currentAdsTime * 1000) |
||||||
|
return () => { |
||||||
|
clearTimeout(timeoutCloseAd) |
||||||
|
} |
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [ |
||||||
|
isNeedToShow, |
||||||
|
isOpenAd, |
||||||
|
isFullscreen, |
||||||
|
currentAdsTime, |
||||||
|
]) |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
close() |
||||||
|
const timeoutCloseBtn = time_close && setTimeout(showCloseBtn, time_close * 1000) |
||||||
|
return () => { |
||||||
|
time_close && clearTimeout(timeoutCloseBtn) |
||||||
|
} |
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [ |
||||||
|
isNeedToShow, |
||||||
|
isOpenAd, |
||||||
|
views?.HOME, |
||||||
|
]) |
||||||
|
|
||||||
|
useEffect(() => { |
||||||
|
if (!isNeedToShow || (!isMatchPage() && !isNeedBanner)) return |
||||||
|
|
||||||
|
(async () => { |
||||||
|
await updateAdsView({ adv_id: id }) |
||||||
|
})() |
||||||
|
sendBannerClickEvent(EventGA.DISPLAY) |
||||||
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
|
}, [id, isNeedToShow]) |
||||||
|
|
||||||
|
return { |
||||||
|
handleClose, |
||||||
|
isNeedToShow, |
||||||
|
isOpenAd, |
||||||
|
isOpenCloseBtn, |
||||||
|
isVideo, |
||||||
|
sendBannerClickEvent, |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,85 @@ |
|||||||
|
import { memo, MouseEvent } from 'react' |
||||||
|
|
||||||
|
import type { AdType } from 'requests' |
||||||
|
|
||||||
|
import { useAd } from './hooks' |
||||||
|
|
||||||
|
import { EventGA } from '../../types' |
||||||
|
|
||||||
|
import { |
||||||
|
AdImg, |
||||||
|
AdVideo, |
||||||
|
AdWrapper, |
||||||
|
LinkWrapper, |
||||||
|
AdsCloseButton, |
||||||
|
} from './styled' |
||||||
|
|
||||||
|
export type AdComponentType = { |
||||||
|
ad: AdType, |
||||||
|
} |
||||||
|
export const AdComponent = memo(({ ad }: AdComponentType) => { |
||||||
|
const { |
||||||
|
link, |
||||||
|
media, |
||||||
|
position, |
||||||
|
} = ad |
||||||
|
|
||||||
|
const { |
||||||
|
handleClose, |
||||||
|
isNeedToShow, |
||||||
|
isOpenAd, |
||||||
|
isOpenCloseBtn, |
||||||
|
isVideo, |
||||||
|
sendBannerClickEvent, |
||||||
|
} = useAd({ ad }) |
||||||
|
|
||||||
|
const close = (e: MouseEvent<HTMLButtonElement>) => { |
||||||
|
e.stopPropagation() |
||||||
|
return handleClose() |
||||||
|
} |
||||||
|
|
||||||
|
const onLinkClick = () => { |
||||||
|
link && sendBannerClickEvent(EventGA.CLICK) |
||||||
|
} |
||||||
|
|
||||||
|
return ( |
||||||
|
position && isOpenAd && isNeedToShow |
||||||
|
? ( |
||||||
|
<AdWrapper |
||||||
|
position={position.id} |
||||||
|
isOpenAd={isOpenAd} |
||||||
|
> |
||||||
|
{isOpenCloseBtn && ( |
||||||
|
<AdsCloseButton |
||||||
|
onClick={close} |
||||||
|
size={12} |
||||||
|
position={position.id} |
||||||
|
/> |
||||||
|
)} |
||||||
|
<LinkWrapper |
||||||
|
href={link} |
||||||
|
target='_blank' |
||||||
|
rel='noreferrer' |
||||||
|
onClick={onLinkClick} |
||||||
|
> |
||||||
|
{isVideo |
||||||
|
? ( |
||||||
|
<AdVideo |
||||||
|
muted={isVideo} |
||||||
|
autoPlay={isVideo} |
||||||
|
loop={isVideo} |
||||||
|
src={media.url} |
||||||
|
position={position.id} |
||||||
|
/> |
||||||
|
) |
||||||
|
: ( |
||||||
|
<AdImg |
||||||
|
src={media.url} |
||||||
|
position={position.id} |
||||||
|
/> |
||||||
|
)} |
||||||
|
</LinkWrapper> |
||||||
|
</AdWrapper> |
||||||
|
) : null |
||||||
|
) |
||||||
|
}) |
||||||
@ -0,0 +1,109 @@ |
|||||||
|
import styled, { css } from 'styled-components/macro' |
||||||
|
|
||||||
|
import includes from 'lodash/includes' |
||||||
|
|
||||||
|
import { CloseButton } from 'features/PopupComponents' |
||||||
|
|
||||||
|
import { |
||||||
|
MATCH_ADS, |
||||||
|
PLAYER_ADS, |
||||||
|
VIEW_ADS, |
||||||
|
} from '../../types' |
||||||
|
|
||||||
|
type Props = { |
||||||
|
position: number, |
||||||
|
} |
||||||
|
|
||||||
|
const header = [7, 8, 9] |
||||||
|
|
||||||
|
const chooseStyle = (type: number) => { |
||||||
|
switch (true) { |
||||||
|
case VIEW_ADS.COLUMN === type: |
||||||
|
return 'grid-row: 1 / 3; img {max-height: none;}' |
||||||
|
case VIEW_ADS.ROW === type: |
||||||
|
return 'grid-column: 1 / 3' |
||||||
|
case VIEW_ADS.SQUARE === type: |
||||||
|
return 'grid-row: 1 / 3; grid-column: 1 / 3; img {max-height: none;}' |
||||||
|
case VIEW_ADS.SECOND_COLUMN === type: |
||||||
|
return 'grid-column: 2 / 3; grid-row: 1 / 1' |
||||||
|
case VIEW_ADS.SECOND_ROW === type: |
||||||
|
return 'grid-column: 1 / 2; grid-row: 2 / 3;' |
||||||
|
case MATCH_ADS.PLAYS_TOP === type: |
||||||
|
return 'margin-left: 14px; height: 48px' |
||||||
|
case MATCH_ADS.PLAYS_BOTTOM === type: |
||||||
|
return 'grid-row: 4; margin-bottom: 12px; height: 48px;' |
||||||
|
case PLAYER_ADS.LEFT_BOTTOM === type: |
||||||
|
return css` |
||||||
|
height: auto;
|
||||||
|
width: 42.4%;
|
||||||
|
bottom: 100px;
|
||||||
|
left: 20px;
|
||||||
|
` |
||||||
|
case PLAYER_ADS.CENTER_BOTTOM === type: |
||||||
|
return css` |
||||||
|
height: 18.3%;
|
||||||
|
width: 81.3%;
|
||||||
|
bottom: 100px;
|
||||||
|
left: 50%;
|
||||||
|
transform: translateX(-50%); |
||||||
|
` |
||||||
|
case PLAYER_ADS.RIGHT === type: |
||||||
|
return css` |
||||||
|
height: 87.2%;
|
||||||
|
width: 18.3%;
|
||||||
|
bottom: 90px;
|
||||||
|
right: 18px; |
||||||
|
` |
||||||
|
case PLAYER_ADS.FULL_SCREEN === type: |
||||||
|
return 'bottom: 0; left: 0;' |
||||||
|
default: |
||||||
|
return '' |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export const AdImg = styled.img<Props>` |
||||||
|
width: 100%; |
||||||
|
min-height: ${({ position }) => (!includes(header, position) && '100%')}; |
||||||
|
max-height: ${({ position }) => (includes(header, position) ? '13rem' : '100%')}; |
||||||
|
cursor: pointer; |
||||||
|
border-radius: 3px; |
||||||
|
` |
||||||
|
|
||||||
|
export const AdVideo = styled.video<Props>` |
||||||
|
object-fit: contain; |
||||||
|
width: 100%; |
||||||
|
cursor: pointer; |
||||||
|
max-height: ${({ position }) => (includes(header, position) ? '283px' : '100%')}; |
||||||
|
background-color: black; |
||||||
|
border-radius: 3px; |
||||||
|
` |
||||||
|
|
||||||
|
export const AdWrapper = styled.div<Props & {isOpenAd: boolean}>` |
||||||
|
position: ${({ position }) => (includes(PLAYER_ADS, position) ? 'absolute' : 'relative')}; |
||||||
|
width: 100%; |
||||||
|
height: 100%; |
||||||
|
z-index: 1; |
||||||
|
|
||||||
|
${({ position }) => chooseStyle(position)}; |
||||||
|
|
||||||
|
display: ${({ isOpenAd }) => (isOpenAd ? '' : 'none')}; |
||||||
|
` |
||||||
|
|
||||||
|
export const AdsCloseButton = styled(CloseButton)<Props>` |
||||||
|
position: absolute; |
||||||
|
right: ${({ position }) => (position === PLAYER_ADS.FULL_SCREEN ? '10px' : '0')}; |
||||||
|
top: ${({ position }) => (position === PLAYER_ADS.FULL_SCREEN ? '10px' : '0')}; |
||||||
|
background: none; |
||||||
|
border-radius: 0; |
||||||
|
z-index: 2; |
||||||
|
cursor: pointer; |
||||||
|
color: #9B9B9B; |
||||||
|
width: 28px; |
||||||
|
height: 28px; |
||||||
|
|
||||||
|
:hover { |
||||||
|
background: none; |
||||||
|
} |
||||||
|
` |
||||||
|
|
||||||
|
export const LinkWrapper = styled.a`` |
||||||
@ -0,0 +1,71 @@ |
|||||||
|
import type { MouseEvent } from 'react' |
||||||
|
|
||||||
|
import includes from 'lodash/includes' |
||||||
|
|
||||||
|
import type { AdType } from 'requests' |
||||||
|
|
||||||
|
import { useAd } from '../AdComponent/hooks' |
||||||
|
import { EventGA, PLAYER_MOBILE_FULL_SCREEN } from '../../types' |
||||||
|
|
||||||
|
import { |
||||||
|
AdsCloseButton, |
||||||
|
Img, |
||||||
|
MobileAdWrapper, |
||||||
|
Video, |
||||||
|
} from './styled' |
||||||
|
|
||||||
|
type MobileAdTypes = { |
||||||
|
ad: AdType, |
||||||
|
} |
||||||
|
|
||||||
|
export const MobileAd = ({ ad }: MobileAdTypes) => { |
||||||
|
const { |
||||||
|
link, |
||||||
|
media, |
||||||
|
position, |
||||||
|
} = ad |
||||||
|
|
||||||
|
const { |
||||||
|
handleClose, |
||||||
|
isNeedToShow, |
||||||
|
isOpenAd, |
||||||
|
isOpenCloseBtn, |
||||||
|
isVideo, |
||||||
|
sendBannerClickEvent, |
||||||
|
} = useAd({ ad }) |
||||||
|
|
||||||
|
const close = (e: MouseEvent<HTMLButtonElement>) => { |
||||||
|
e.stopPropagation() |
||||||
|
return handleClose() |
||||||
|
} |
||||||
|
|
||||||
|
const onLinkClick = () => { |
||||||
|
if (link) { |
||||||
|
sendBannerClickEvent(EventGA.CLICK) |
||||||
|
window.open(link, '_blank') |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
return ( |
||||||
|
position && isOpenAd && isNeedToShow ? ( |
||||||
|
<MobileAdWrapper |
||||||
|
position={position.id} |
||||||
|
onClick={onLinkClick} |
||||||
|
> |
||||||
|
{isOpenCloseBtn |
||||||
|
&& ( |
||||||
|
<AdsCloseButton |
||||||
|
position={position.id} |
||||||
|
onClick={close} |
||||||
|
size={includes(PLAYER_MOBILE_FULL_SCREEN, position.id) ? 12 : 8} |
||||||
|
/> |
||||||
|
)} |
||||||
|
{isVideo |
||||||
|
? <Video position={position.id} src={media.url} /> |
||||||
|
: ( |
||||||
|
<Img position={position.id} src={media.url} /> |
||||||
|
)} |
||||||
|
</MobileAdWrapper> |
||||||
|
) : null |
||||||
|
) |
||||||
|
} |
||||||
@ -0,0 +1,112 @@ |
|||||||
|
import styled, { css } from 'styled-components/macro' |
||||||
|
|
||||||
|
import includes from 'lodash/includes' |
||||||
|
|
||||||
|
import { CloseButton } from 'features/PopupComponents' |
||||||
|
|
||||||
|
import { |
||||||
|
MATCH_ADS, |
||||||
|
PLAYER_MOBILE_FULL_SCREEN, |
||||||
|
PLAYER_MOBILE_ADS, |
||||||
|
} from '../../types' |
||||||
|
|
||||||
|
type Props = { |
||||||
|
position: number, |
||||||
|
} |
||||||
|
|
||||||
|
const matchMobileAds = [16, 17, 22, 23, 24] |
||||||
|
|
||||||
|
const chooseStyle = (type: number) => { |
||||||
|
switch (true) { |
||||||
|
case MATCH_ADS.PLAYS_BOTTOM_MOBILE === type: |
||||||
|
return css` |
||||||
|
grid-row: 4;
|
||||||
|
margin-bottom: 12px;
|
||||||
|
height: 48px; |
||||||
|
` |
||||||
|
case PLAYER_MOBILE_ADS === type: |
||||||
|
return css` |
||||||
|
position: absolute; |
||||||
|
width: 92%;
|
||||||
|
bottom: 50px;
|
||||||
|
left: 15px; |
||||||
|
` |
||||||
|
case PLAYER_MOBILE_FULL_SCREEN.VERTICAL_FULL_SCREEN === type: |
||||||
|
case PLAYER_MOBILE_FULL_SCREEN.HORIZONTAL_FULL_SCREEN === type: |
||||||
|
return css` |
||||||
|
position: absolute; |
||||||
|
top: 0; |
||||||
|
left: 0; |
||||||
|
height: 100%; |
||||||
|
padding: 5px;
|
||||||
|
background-color: rgba(0, 0, 0, 0.7); |
||||||
|
` |
||||||
|
default: |
||||||
|
return '' |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
export const MobileAdWrapper = styled.div<Props>` |
||||||
|
position: relative; |
||||||
|
width: 100%; |
||||||
|
z-index: ${({ position }) => (includes(PLAYER_MOBILE_FULL_SCREEN, position) ? '101' : '100')}; |
||||||
|
|
||||||
|
${({ position }) => chooseStyle(position)}; |
||||||
|
` |
||||||
|
|
||||||
|
export const AdsCloseButton = styled(CloseButton)<Props>` |
||||||
|
position: absolute; |
||||||
|
right: ${({ position }) => (includes(PLAYER_MOBILE_FULL_SCREEN, position) ? '-5px' : '-10px')}; |
||||||
|
top: ${({ position }) => (includes(PLAYER_MOBILE_FULL_SCREEN, position) ? '15px' : '10px')}; |
||||||
|
background: none; |
||||||
|
border-radius: 0; |
||||||
|
transform: translate(-50%, -50%); |
||||||
|
z-index: 2; |
||||||
|
color: #9B9B9B; |
||||||
|
` |
||||||
|
|
||||||
|
export const Img = styled.img<Props>` |
||||||
|
border-radius: 2px; |
||||||
|
width: 100%; |
||||||
|
|
||||||
|
object-fit: ${({ position }) => { |
||||||
|
switch (true) { |
||||||
|
case position === PLAYER_MOBILE_FULL_SCREEN.VERTICAL_FULL_SCREEN: |
||||||
|
return 'fill' |
||||||
|
case position === MATCH_ADS.PLAYS_TOP_MOBILE: |
||||||
|
return 'contain' |
||||||
|
default: |
||||||
|
return 'cover' |
||||||
|
} |
||||||
|
}}; |
||||||
|
|
||||||
|
height: ${({ position }) => { |
||||||
|
switch (true) { |
||||||
|
case position === 10: |
||||||
|
return '50px' |
||||||
|
case includes(matchMobileAds, position): |
||||||
|
return '100%' |
||||||
|
default: |
||||||
|
return '75px' |
||||||
|
} |
||||||
|
}} |
||||||
|
` |
||||||
|
|
||||||
|
export const Video = styled.video<Props>` |
||||||
|
max-height: 100%; |
||||||
|
object-fit: cover; |
||||||
|
min-width: 100%; |
||||||
|
height: ${({ position }) => (position === 10 ? '50px' : '75px')}; |
||||||
|
border-radius: 2px; |
||||||
|
|
||||||
|
height: ${({ position }) => { |
||||||
|
switch (true) { |
||||||
|
case position === 10: |
||||||
|
return '50px' |
||||||
|
case position === MATCH_ADS.PLAYS_TOP_MOBILE: |
||||||
|
return '48px' |
||||||
|
default: |
||||||
|
return '75px' |
||||||
|
} |
||||||
|
}} |
||||||
|
` |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
import type { AdResponse, AdsListType } from 'requests' |
||||||
|
|
||||||
|
export const calcMaxAdDurationAds = (advertisements: AdResponse) => { |
||||||
|
const allAds = Object.values(advertisements) |
||||||
|
|
||||||
|
const combineAds = allAds.reduce((result, currentAd) => { |
||||||
|
result.push(...currentAd) |
||||||
|
|
||||||
|
return result |
||||||
|
}, [] as AdsListType) |
||||||
|
|
||||||
|
const maxDuration = combineAds |
||||||
|
.reduce((result, { duration }) => Math.max(result, duration), 0) |
||||||
|
|
||||||
|
return maxDuration |
||||||
|
} |
||||||
@ -0,0 +1 @@ |
|||||||
|
export * from './isVideo' |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
const regexp = /^https?:\/\/\S+(?:mp4)$/ |
||||||
|
export const checkVideo = (url: string) => regexp.test(url) |
||||||
@ -0,0 +1,65 @@ |
|||||||
|
import { useMemo } from 'react' |
||||||
|
|
||||||
|
import { useQuery } from 'react-query' |
||||||
|
|
||||||
|
import { useRecoilState } from 'recoil' |
||||||
|
|
||||||
|
import { isMobileDevice, querieKeys } from 'config' |
||||||
|
|
||||||
|
import { getAds } from 'requests' |
||||||
|
|
||||||
|
import { isMatchPage } from 'helpers/isMatchPage' |
||||||
|
import { useLang } from 'features/LexicsStore/hooks/useLang' |
||||||
|
import { useAuthStore } from 'features/AuthStore' |
||||||
|
|
||||||
|
import { |
||||||
|
DeviceType, |
||||||
|
PageType, |
||||||
|
} from './types' |
||||||
|
import { calcMaxAdDurationAds } from './helpers/calcMaxDurationAds' |
||||||
|
import { adsStore } from '../../pages/HighlightsPage/storeHighlightsAtoms' |
||||||
|
|
||||||
|
type Props = { |
||||||
|
matchId?: number, |
||||||
|
sportType?: number, |
||||||
|
tournamentId?: number, |
||||||
|
} |
||||||
|
|
||||||
|
export const useAds = ({ |
||||||
|
matchId, |
||||||
|
sportType, |
||||||
|
tournamentId, |
||||||
|
}: Props) => { |
||||||
|
const [ads, setAds] = useRecoilState(adsStore) |
||||||
|
const { lang } = useLang() |
||||||
|
const { user } = useAuthStore() |
||||||
|
|
||||||
|
useQuery({ |
||||||
|
enabled: isMatchPage() ? (!!user && !!tournamentId) : !!user, |
||||||
|
queryFn: async () => { |
||||||
|
const adsList = await getAds({ |
||||||
|
client_type: isMobileDevice ? DeviceType.MOBILE : DeviceType.WEB, |
||||||
|
language: lang, |
||||||
|
type_id: isMatchPage() ? PageType.MATCH : PageType.HOME, |
||||||
|
...isMatchPage() && { |
||||||
|
matches: [{ |
||||||
|
match_id: matchId, |
||||||
|
sport_id: sportType, |
||||||
|
}], |
||||||
|
tournaments: [{ |
||||||
|
sport_id: sportType, |
||||||
|
tournament_id: tournamentId, |
||||||
|
}], |
||||||
|
}, |
||||||
|
}) |
||||||
|
adsList && setAds(adsList) |
||||||
|
return adsList |
||||||
|
}, |
||||||
|
queryKey: [querieKeys.ads, matchId], |
||||||
|
staleTime: useMemo(() => Math.max(calcMaxAdDurationAds(ads), 60 * 1000), [ads]), |
||||||
|
}) |
||||||
|
|
||||||
|
return { |
||||||
|
ads, |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,31 @@ |
|||||||
|
import type { AdType } from 'requests' |
||||||
|
|
||||||
|
import { isMobileDevice } from 'config' |
||||||
|
|
||||||
|
import { AdComponent } from './components/AdComponent' |
||||||
|
import { AdsPropsType } from './types' |
||||||
|
import { MobileAd } from './components/MobileAd' |
||||||
|
|
||||||
|
import { |
||||||
|
HeaderWrapAd, |
||||||
|
} from './styled' |
||||||
|
|
||||||
|
export const HeaderAds = ({ ads }: AdsPropsType) => ( |
||||||
|
ads?.length ? ( |
||||||
|
<HeaderWrapAd column={ads?.length}> |
||||||
|
{ads.map((ad: AdType) => ( |
||||||
|
!isMobileDevice ? ( |
||||||
|
<AdComponent |
||||||
|
ad={ad} |
||||||
|
key={ad.id} |
||||||
|
/> |
||||||
|
) : ( |
||||||
|
<MobileAd |
||||||
|
ad={ad} |
||||||
|
key={ad.id} |
||||||
|
/> |
||||||
|
) |
||||||
|
))} |
||||||
|
</HeaderWrapAd> |
||||||
|
) : null |
||||||
|
) |
||||||
@ -0,0 +1,16 @@ |
|||||||
|
import styled, { css } from 'styled-components/macro' |
||||||
|
|
||||||
|
import { isMobileDevice } from 'config' |
||||||
|
|
||||||
|
export const HeaderWrapAd = styled.div<{column: number}>` |
||||||
|
width: 100%; |
||||||
|
margin-bottom: 0.7rem; |
||||||
|
display: grid; |
||||||
|
grid-column-gap: 0.9rem; |
||||||
|
grid-template-columns: ${({ column }) => (column > 1 ? `repeat(${column},${16.3 * 6 / column}%)` : 'repeat(1, 98.7%)')}; |
||||||
|
|
||||||
|
${isMobileDevice && css` |
||||||
|
padding: 0 0.71rem; |
||||||
|
grid-template-columns: none; |
||||||
|
`}}
|
||||||
|
` |
||||||
@ -0,0 +1,57 @@ |
|||||||
|
import { AdsListType } from 'requests' |
||||||
|
|
||||||
|
export enum PageType { |
||||||
|
HOME = 1, |
||||||
|
MATCH = 2, |
||||||
|
} |
||||||
|
|
||||||
|
export enum DeviceType { |
||||||
|
MOBILE = 'mobile', |
||||||
|
WEB = 'web' |
||||||
|
} |
||||||
|
|
||||||
|
export type ViewsType = Partial<Record<keyof typeof PageType, number>> |
||||||
|
|
||||||
|
export enum EventGA { |
||||||
|
CLICK = 'banner_click', |
||||||
|
CLOSE = 'banner_close', |
||||||
|
DISPLAY = 'banner_display' |
||||||
|
} |
||||||
|
|
||||||
|
export enum VIEW_ADS { |
||||||
|
ROW = 4, |
||||||
|
COLUMN = 5, |
||||||
|
SQUARE = 6, |
||||||
|
SECOND_COLUMN = 2, |
||||||
|
SECOND_ROW = 3, |
||||||
|
MOBILE_IN_COLLAPSE_HEADER = 12, |
||||||
|
MOBILE_IN_COLLAPSE_FOOTER = 25 |
||||||
|
} |
||||||
|
|
||||||
|
export const HEADER_MOBILE_ADS = [10, 11] |
||||||
|
|
||||||
|
export enum MATCH_ADS { |
||||||
|
WATCH_TOP = 13, |
||||||
|
PLAYS_TOP = 14, |
||||||
|
PLAYS_BOTTOM = 15, |
||||||
|
PLAYS_TOP_MOBILE = 16, |
||||||
|
PLAYS_BOTTOM_MOBILE = 17, |
||||||
|
} |
||||||
|
|
||||||
|
export enum PLAYER_ADS { |
||||||
|
LEFT_BOTTOM = 18, |
||||||
|
CENTER_BOTTOM = 19, |
||||||
|
RIGHT = 20, |
||||||
|
FULL_SCREEN = 21, |
||||||
|
} |
||||||
|
|
||||||
|
export const PLAYER_MOBILE_ADS = 22 |
||||||
|
|
||||||
|
export enum PLAYER_MOBILE_FULL_SCREEN { |
||||||
|
VERTICAL_FULL_SCREEN = 23, |
||||||
|
HORIZONTAL_FULL_SCREEN = 24, |
||||||
|
} |
||||||
|
|
||||||
|
export type AdsPropsType = Record<'ads', AdsListType | undefined> |
||||||
|
|
||||||
|
export const adsViews = 'adsViews' |
||||||
@ -0,0 +1 @@ |
|||||||
|
export const COUNTRY = 'COUNTRY' |
||||||
@ -1,5 +1,7 @@ |
|||||||
export const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) |
export const device = navigator.userAgent |
||||||
|
|
||||||
export const isAndroid = /Android/.test(navigator.userAgent) |
export const isIOS = /iPad|iPhone|iPod/.test(device) |
||||||
|
|
||||||
export const isMobileDevice = /iPhone|Android/.test(navigator.userAgent) |
export const isAndroid = /Android/.test(device) |
||||||
|
|
||||||
|
export const isMobileDevice = /iPhone|Android/.test(device) |
||||||
|
|||||||
@ -0,0 +1,65 @@ |
|||||||
|
import { callApi } from 'helpers' |
||||||
|
|
||||||
|
import { ADS_API_URL } from 'config' |
||||||
|
|
||||||
|
import { DeviceType } from '../../components/Ads/types' |
||||||
|
|
||||||
|
type MatchesParams = { |
||||||
|
match_id?: number, |
||||||
|
sport_id?: number, |
||||||
|
} |
||||||
|
|
||||||
|
type TournamentsParams = { |
||||||
|
sport_id?: number, |
||||||
|
tournament_id?: number, |
||||||
|
} |
||||||
|
|
||||||
|
export type AdsParams = { |
||||||
|
client_type: DeviceType, |
||||||
|
language: string, |
||||||
|
matches?: Array<MatchesParams>, |
||||||
|
tournaments?: Array<TournamentsParams>, |
||||||
|
type_id: number, |
||||||
|
} |
||||||
|
|
||||||
|
export type AdType = { |
||||||
|
duration: number, |
||||||
|
frequency: number, |
||||||
|
id: number, |
||||||
|
impressions: number, |
||||||
|
link: string, |
||||||
|
media: { |
||||||
|
url: string, |
||||||
|
}, |
||||||
|
name: string, |
||||||
|
position: { |
||||||
|
id: number, |
||||||
|
name_eng: string, |
||||||
|
name_rus: string, |
||||||
|
source_type: string, |
||||||
|
}, |
||||||
|
remaining_views: number, |
||||||
|
time_close: number, |
||||||
|
type: { |
||||||
|
id: number, |
||||||
|
name_eng: string, |
||||||
|
name_rus: string, |
||||||
|
}, |
||||||
|
} |
||||||
|
|
||||||
|
export type PositionName = 'header' | 'block' | 'match_cell' | 'mobile' | 'match' |
||||||
|
|
||||||
|
export type AdResponse = Record<PositionName, AdsListType> |
||||||
|
|
||||||
|
export type AdsListType = Array<AdType> |
||||||
|
|
||||||
|
export const getAds = (params: AdsParams): Promise<AdResponse> => { |
||||||
|
const config = { |
||||||
|
body: params, |
||||||
|
} |
||||||
|
|
||||||
|
return callApi({ |
||||||
|
config, |
||||||
|
url: ADS_API_URL, |
||||||
|
}) |
||||||
|
} |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
export * from './getAds' |
||||||
|
export * from './updateAdsView' |
||||||
@ -0,0 +1,29 @@ |
|||||||
|
import { callApi } from 'helpers' |
||||||
|
|
||||||
|
import { ADS_API_URL } from 'config' |
||||||
|
|
||||||
|
export type AdsViewParams = { |
||||||
|
adv_id: number, |
||||||
|
} |
||||||
|
|
||||||
|
type AdsViewResponse = { |
||||||
|
data: string, |
||||||
|
message: string, |
||||||
|
reason: string, |
||||||
|
status: 'failed' | 'success', |
||||||
|
} |
||||||
|
|
||||||
|
export const updateAdsView = ( |
||||||
|
{ adv_id }: AdsViewParams, |
||||||
|
): Promise<AdsViewResponse> => { |
||||||
|
const config = { |
||||||
|
body: { |
||||||
|
adv_id, |
||||||
|
}, |
||||||
|
} |
||||||
|
|
||||||
|
return callApi({ |
||||||
|
config, |
||||||
|
url: `${ADS_API_URL}/${adv_id}/view`, |
||||||
|
}) |
||||||
|
} |
||||||
@ -1,31 +0,0 @@ |
|||||||
/* eslint-disable */ |
|
||||||
import { |
|
||||||
createServer, |
|
||||||
Model, |
|
||||||
} from 'miragejs' |
|
||||||
|
|
||||||
import { ResponseType } from 'requests/getFavouriteTeam' |
|
||||||
|
|
||||||
import { surveys } from './fixtures/surveys' |
|
||||||
|
|
||||||
export function makeServer({ environment = 'test' } = {}) { |
|
||||||
const server = createServer({ |
|
||||||
environment, |
|
||||||
factories: {}, |
|
||||||
fixtures: { |
|
||||||
surveys, |
|
||||||
}, |
|
||||||
models: { |
|
||||||
surveys: Model.extend<Partial<ResponseType>>({}), |
|
||||||
}, |
|
||||||
routes() { |
|
||||||
this.passthrough('https://api.insports.tv/***') |
|
||||||
this.passthrough('https://insports.tv/***') |
|
||||||
this.passthrough('https://images.insports.tv/***') |
|
||||||
this.passthrough('https://auth.insports.tv/***') |
|
||||||
this.passthrough('${URL_AWS}/***') |
|
||||||
this.get('https://api.insports.tv/v1/survey/teams/1/131/30', (schema: any) => schema.all('surveys').models[0].attrs) |
|
||||||
}, |
|
||||||
}) |
|
||||||
return server |
|
||||||
} |
|
||||||
@ -0,0 +1,592 @@ |
|||||||
|
/* eslint-disable */ |
||||||
|
export const getAds = () => { |
||||||
|
return { |
||||||
|
"mobile": [ |
||||||
|
{ |
||||||
|
"id": 71, |
||||||
|
"name": "Test 2", |
||||||
|
"type": { |
||||||
|
"id": 1, |
||||||
|
"name_eng": "Main", |
||||||
|
"name_rus": "Главная" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 12, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web main ad 2 (1x1)", |
||||||
|
"name_rus": "Веб: главная 2 (1x1)" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 2, |
||||||
|
"duration": 120, |
||||||
|
"time_close": 150, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/71/en/web.png" |
||||||
|
}, |
||||||
|
"remaining_views": 9 |
||||||
|
},{ |
||||||
|
"id": 71, |
||||||
|
"name": "Test 2", |
||||||
|
"type": { |
||||||
|
"id": 1, |
||||||
|
"name_eng": "Main", |
||||||
|
"name_rus": "Главная" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 25, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web main ad 2 (1x1)", |
||||||
|
"name_rus": "Веб: главная 2 (1x1)" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 2, |
||||||
|
"duration": 120, |
||||||
|
"time_close": 150, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/71/en/web.png" |
||||||
|
}, |
||||||
|
"remaining_views": 9 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": 72, |
||||||
|
"name": "Best mens boots for sport advertise here", |
||||||
|
"type": { |
||||||
|
"id": 1, |
||||||
|
"name_eng": "Main", |
||||||
|
"name_rus": "Главная" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 11, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web main ad 7 (1x1)", |
||||||
|
"name_rus": "Веб: главная 7 (1x1)" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 2, |
||||||
|
"frequency": 1, |
||||||
|
"duration": 300, |
||||||
|
"time_close": 500, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/72/en/web.png" |
||||||
|
}, |
||||||
|
"remaining_views": 9 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": 85, |
||||||
|
"name": "Test 16", |
||||||
|
"type": { |
||||||
|
"id": 2, |
||||||
|
"name_eng": "Match", |
||||||
|
"name_rus": "Матч" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 16, |
||||||
|
"source_type": "Mobile", |
||||||
|
"name_eng": "Web top side ad horizontal", |
||||||
|
"name_rus": "Веб: верхняя, боковая, по горизонтали" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 60, |
||||||
|
"frequency": 5, |
||||||
|
"duration": 12000, |
||||||
|
"time_close": 1, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/85/en/mobile.png" |
||||||
|
}, |
||||||
|
"remaining_views": 60 |
||||||
|
}, |
||||||
|
|
||||||
|
{ |
||||||
|
"id": 86, |
||||||
|
"name": "Test 17", |
||||||
|
"type": { |
||||||
|
"id": 2, |
||||||
|
"name_eng": "Match", |
||||||
|
"name_rus": "Матч" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 17, |
||||||
|
"source_type": "Mobile", |
||||||
|
"name_eng": "Web top side ad horizontal", |
||||||
|
"name_rus": "Веб: верхняя, боковая, по горизонтали" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 5, |
||||||
|
"duration": 12000, |
||||||
|
"time_close": 1, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/86/en/mobile.png" |
||||||
|
}, |
||||||
|
"remaining_views": 10 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": 91, |
||||||
|
"name": "Test 22", |
||||||
|
"type": { |
||||||
|
"id": 3, |
||||||
|
"name_eng": "Player", |
||||||
|
"name_rus": "Плеер" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 22, |
||||||
|
"source_type": "Mobile", |
||||||
|
"name_eng": "Web top side ad horizontal", |
||||||
|
"name_rus": "Веб: верхняя, боковая, по горизонтали" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 10, |
||||||
|
"duration": 12000, |
||||||
|
"time_close": 1, |
||||||
|
"media": { |
||||||
|
"url": "https://i.imgur.com/5Tbygu1.png" |
||||||
|
}, |
||||||
|
"remaining_views": 10 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": 92, |
||||||
|
"name": "Test 23", |
||||||
|
"type": { |
||||||
|
"id": 3, |
||||||
|
"name_eng": "Player", |
||||||
|
"name_rus": "Плеер" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 23, |
||||||
|
"source_type": "Mobile", |
||||||
|
"name_eng": "Web top side ad horizontal", |
||||||
|
"name_rus": "Веб: верхняя, боковая, по горизонтали" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 5, |
||||||
|
"duration": 12000, |
||||||
|
"time_close": 1, |
||||||
|
"media": { |
||||||
|
"url": "https://i.imgur.com/PyZwEDq.png" |
||||||
|
}, |
||||||
|
"remaining_views": 10 |
||||||
|
}, |
||||||
|
// {
|
||||||
|
// "id": 93,
|
||||||
|
// "name": "Test 24",
|
||||||
|
// "type": {
|
||||||
|
// "id": 3,
|
||||||
|
// "name_eng": "Player",
|
||||||
|
// "name_rus": "Плеер"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 24,
|
||||||
|
// "source_type": "Mobile",
|
||||||
|
// "name_eng": "Web top side ad horizontal",
|
||||||
|
// "name_rus": "Веб: верхняя, боковая, по горизонтали"
|
||||||
|
// },
|
||||||
|
// "link": "https://www.google.com/",
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 5,
|
||||||
|
// "duration": 12000,
|
||||||
|
// "time_close": 1,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://i.imgur.com/iwihMdx.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
], |
||||||
|
"match_cell": [ |
||||||
|
{ |
||||||
|
"id": 71, |
||||||
|
"name": "Test 2", |
||||||
|
"type": { |
||||||
|
"id": 1, |
||||||
|
"name_eng": "Main", |
||||||
|
"name_rus": "Главная" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 1, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web main ad 2 (1x1)", |
||||||
|
"name_rus": "Веб: главная 2 (1x1)" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 2, |
||||||
|
"duration": 15, |
||||||
|
"time_close": 15, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/71/en/web.png" |
||||||
|
}, |
||||||
|
"remaining_views": 9 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": 71, |
||||||
|
"name": "Test 2", |
||||||
|
"type": { |
||||||
|
"id": 1, |
||||||
|
"name_eng": "Main", |
||||||
|
"name_rus": "Главная" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 2, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web main ad 2 (1x1)", |
||||||
|
"name_rus": "Веб: главная 2 (1x1)" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 2, |
||||||
|
"duration": 12, |
||||||
|
"time_close": 15, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/71/en/web.png" |
||||||
|
}, |
||||||
|
"remaining_views": 9 |
||||||
|
}, |
||||||
|
{ |
||||||
|
"id": 72, |
||||||
|
"name": "Test 3", |
||||||
|
"type": { |
||||||
|
"id": 1, |
||||||
|
"name_eng": "Main", |
||||||
|
"name_rus": "Главная" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 3, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web main ad 7 (1x1)", |
||||||
|
"name_rus": "Веб: главная 7 (1x1)" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 3, |
||||||
|
"duration": 15, |
||||||
|
"time_close": 15, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/72/en/web.png" |
||||||
|
}, |
||||||
|
"remaining_views": 9 |
||||||
|
} |
||||||
|
], |
||||||
|
"header": [ |
||||||
|
// {
|
||||||
|
// "id": 77,
|
||||||
|
// "name": "Test 8",
|
||||||
|
// "type": {
|
||||||
|
// "id": 1,
|
||||||
|
// "name_eng": "Main",
|
||||||
|
// "name_rus": "Главная"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 8,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web main ad 2 (3x1)",
|
||||||
|
// "name_rus": "Веб: главная 2(3x1)"
|
||||||
|
// },
|
||||||
|
// "link": null,
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 2,
|
||||||
|
// "duration": 120,
|
||||||
|
// "time_close": 15,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://cf-aws-staging.insports.tv/media/folder/77/en/web.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "id": 78,
|
||||||
|
// "name": "Test 9",
|
||||||
|
// "type": {
|
||||||
|
// "id": 1,
|
||||||
|
// "name_eng": "Main",
|
||||||
|
// "name_rus": "Главная"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 9,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web main ad (6x1)",
|
||||||
|
// "name_rus": "Веб: главная (6x1)"
|
||||||
|
// },
|
||||||
|
// "link": null,
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 2,
|
||||||
|
// "duration": 10,
|
||||||
|
// "time_close": 15,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://cf-aws-staging.insports.tv/media/folder/78/en/web.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 15
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "id": 76,
|
||||||
|
// "name": "Test 7",
|
||||||
|
// "type": {
|
||||||
|
// "id": 1,
|
||||||
|
// "name_eng": "Main",
|
||||||
|
// "name_rus": "Главная"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 7,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web main ad (3x1)",
|
||||||
|
// "name_rus": "Веб: главная (3x1)"
|
||||||
|
// },
|
||||||
|
// "link": null,
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 4,
|
||||||
|
// "duration": 10,
|
||||||
|
// "time_close": 15,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://cf-aws-staging.insports.tv/media/folder/76/en/web.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 15
|
||||||
|
// }
|
||||||
|
], |
||||||
|
"block": [ |
||||||
|
// {
|
||||||
|
// "id": 75,
|
||||||
|
// "name": "Test 6",
|
||||||
|
// "type": {
|
||||||
|
// "id": 1,
|
||||||
|
// "name_eng": "Main",
|
||||||
|
// "name_rus": "Главная"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 6,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web main ad (2x2)",
|
||||||
|
// "name_rus": "Веб: главная (2x2)"
|
||||||
|
// },
|
||||||
|
// "link": null,
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 3,
|
||||||
|
// "duration": 120,
|
||||||
|
// "time_close": null,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://cf-aws-staging.insports.tv/media/folder/75/en/web.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "id": 73,
|
||||||
|
// "name": "Test 4",
|
||||||
|
// "type": {
|
||||||
|
// "id": 1,
|
||||||
|
// "name_eng": "Main",
|
||||||
|
// "name_rus": "Главная"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 4,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web main ad (2x1)",
|
||||||
|
// "name_rus": "Веб: главная (2x1)"
|
||||||
|
// },
|
||||||
|
// "link": null,
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 1,
|
||||||
|
// "duration": 120,
|
||||||
|
// "time_close": null,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://cf-aws-staging.insports.tv/media/folder/73/en/web.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 9
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "id": 74,
|
||||||
|
// "name": "Test 5",
|
||||||
|
// "type": {
|
||||||
|
// "id": 1,
|
||||||
|
// "name_eng": "Main",
|
||||||
|
// "name_rus": "Главная"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 5,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web main ad (1x2)",
|
||||||
|
// "name_rus": "Веб: главная (1x2)"
|
||||||
|
// },
|
||||||
|
// "link": null,
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 2,
|
||||||
|
// "duration": 120000,
|
||||||
|
// "time_close": 1,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://cf-aws-staging.insports.tv/media/folder/74/en/web.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 9
|
||||||
|
// }
|
||||||
|
], |
||||||
|
"match": [ |
||||||
|
// {
|
||||||
|
// "id": 82,
|
||||||
|
// "name": "Test 13",
|
||||||
|
// "type": {
|
||||||
|
// "id": 2,
|
||||||
|
// "name_eng": "Match",
|
||||||
|
// "name_rus": "Матч"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 13,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web top side ad horizontal",
|
||||||
|
// "name_rus": "Веб: верхняя, боковая, по горизонтали"
|
||||||
|
// },
|
||||||
|
// "link": "https://www.google.com/",
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 10,
|
||||||
|
// "duration": 10,
|
||||||
|
// "time_close": 3,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://i.imgur.com/B0odUkf.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "id": 83,
|
||||||
|
// "name": "Test 14",
|
||||||
|
// "type": {
|
||||||
|
// "id": 2,
|
||||||
|
// "name_eng": "Match",
|
||||||
|
// "name_rus": "Матч"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 14,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web top side ad horizontal",
|
||||||
|
// "name_rus": "Веб: верхняя, боковая, по горизонтали"
|
||||||
|
// },
|
||||||
|
// "link": "https://www.google.com/",
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 5,
|
||||||
|
// "duration": 12000,
|
||||||
|
// "time_close": 1,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://i.imgur.com/KcJhEcu.jpg"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
{ |
||||||
|
"id": 84, |
||||||
|
"name": "Test 15", |
||||||
|
"type": { |
||||||
|
"id": 2, |
||||||
|
"name_eng": "Match", |
||||||
|
"name_rus": "Матч" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 15, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web top side ad horizontal", |
||||||
|
"name_rus": "Веб: верхняя, боковая, по горизонтали" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 10, |
||||||
|
"duration": 5, |
||||||
|
"time_close": 1, |
||||||
|
"media": { |
||||||
|
"url": "https://cf-aws-staging.insports.tv/media/folder/84/en/web.png" |
||||||
|
}, |
||||||
|
"remaining_views": 10 |
||||||
|
}, |
||||||
|
// {
|
||||||
|
// "id": 87,
|
||||||
|
// "name": "Test 18",
|
||||||
|
// "type": {
|
||||||
|
// "id": 3,
|
||||||
|
// "name_eng": "Player",
|
||||||
|
// "name_rus": "Плеер"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 18,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web top side ad horizontal",
|
||||||
|
// "name_rus": "Веб: верхняя, боковая, по горизонтали"
|
||||||
|
// },
|
||||||
|
// "link": "https://www.google.com/",
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 100,
|
||||||
|
// "duration": 12000,
|
||||||
|
// "time_close": 1,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://i.imgur.com/xWlogZt.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "id": 88,
|
||||||
|
// "name": "Test 19",
|
||||||
|
// "type": {
|
||||||
|
// "id": 3,
|
||||||
|
// "name_eng": "Player",
|
||||||
|
// "name_rus": "Плеер"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 19,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web top side ad horizontal",
|
||||||
|
// "name_rus": "Веб: верхняя, боковая, по горизонтали"
|
||||||
|
// },
|
||||||
|
// "link": "https://www.google.com/",
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 100,
|
||||||
|
// "duration": 12000,
|
||||||
|
// "time_close": 1,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://i.imgur.com/u9cfGGs.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
// {
|
||||||
|
// "id": 89,
|
||||||
|
// "name": "Test 20",
|
||||||
|
// "type": {
|
||||||
|
// "id": 3,
|
||||||
|
// "name_eng": "Player",
|
||||||
|
// "name_rus": "Плеер"
|
||||||
|
// },
|
||||||
|
// "position": {
|
||||||
|
// "id": 20,
|
||||||
|
// "source_type": "Web",
|
||||||
|
// "name_eng": "Web top side ad horizontal",
|
||||||
|
// "name_rus": "Веб: верхняя, боковая, по горизонтали"
|
||||||
|
// },
|
||||||
|
// "link": "https://www.google.com/",
|
||||||
|
// "impressions": 10,
|
||||||
|
// "frequency": 100,
|
||||||
|
// "duration": 12000,
|
||||||
|
// "time_close": 1,
|
||||||
|
// "media": {
|
||||||
|
// "url": "https://i.imgur.com/XP1ZIQC.png"
|
||||||
|
// },
|
||||||
|
// "remaining_views": 10
|
||||||
|
// },
|
||||||
|
//
|
||||||
|
{ |
||||||
|
"id": 90, |
||||||
|
"name": "Test 21", |
||||||
|
"type": { |
||||||
|
"id": 3, |
||||||
|
"name_eng": "Player", |
||||||
|
"name_rus": "Плеер" |
||||||
|
}, |
||||||
|
"position": { |
||||||
|
"id": 21, |
||||||
|
"source_type": "Web", |
||||||
|
"name_eng": "Web top side ad horizontal", |
||||||
|
"name_rus": "Веб: верхняя, боковая, по горизонтали" |
||||||
|
}, |
||||||
|
"link": "https://www.google.com/", |
||||||
|
"impressions": 10, |
||||||
|
"frequency": 5, |
||||||
|
"duration": 10, |
||||||
|
"time_close": 3, |
||||||
|
"media": { |
||||||
|
"url": "https://i.imgur.com/PaiZdTd.png" |
||||||
|
}, |
||||||
|
"remaining_views": 10 |
||||||
|
}, |
||||||
|
], |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,2 @@ |
|||||||
|
export * from './getAds' |
||||||
|
export * from './surveys' |
||||||
@ -0,0 +1,8 @@ |
|||||||
|
/* eslint-disable */ |
||||||
|
import { Model } from 'miragejs' |
||||||
|
import type { ResponseType, AdResponse } from 'requests' |
||||||
|
|
||||||
|
export const models = { |
||||||
|
ads: Model.extend<Partial<AdResponse>>({}), |
||||||
|
surveys: Model.extend<Partial<ResponseType>>({}), |
||||||
|
} |
||||||
@ -0,0 +1,44 @@ |
|||||||
|
/* eslint-disable */ |
||||||
|
import { |
||||||
|
createServer, |
||||||
|
} from 'miragejs' |
||||||
|
|
||||||
|
import { |
||||||
|
ADS_API_URL, |
||||||
|
APIS, |
||||||
|
AUTH_SERVICE, |
||||||
|
STATS_API_URL, |
||||||
|
URL_AWS, |
||||||
|
VIEWS_API, |
||||||
|
} from 'config' |
||||||
|
import { API_ROOT } from 'features/AuthServiceApp/config/routes' |
||||||
|
|
||||||
|
import { surveys, getAds } from './fixtures' |
||||||
|
import { models } from './models' |
||||||
|
|
||||||
|
|
||||||
|
const mainDomain = 'insports.tv' |
||||||
|
export function makeServer({ environment = 'test' } = {}) { |
||||||
|
const server = createServer({ |
||||||
|
environment, |
||||||
|
fixtures: { |
||||||
|
surveys, |
||||||
|
ads: getAds(), |
||||||
|
}, |
||||||
|
models: models, |
||||||
|
routes() { |
||||||
|
this.passthrough(`${API_ROOT}/***`) |
||||||
|
this.passthrough(`${VIEWS_API}/***`) |
||||||
|
this.passthrough(`${STATS_API_URL}/***`) |
||||||
|
this.passthrough(`${APIS.production.api}/***`) |
||||||
|
this.passthrough(`${APIS.staging.api}/***`) |
||||||
|
this.passthrough(`${AUTH_SERVICE}/***`) |
||||||
|
this.passthrough(`https://${mainDomain}/***`) |
||||||
|
this.passthrough(`https://images.${mainDomain}/***`) |
||||||
|
this.passthrough(`${URL_AWS}/***`) |
||||||
|
this.post(`${ADS_API_URL}`, getAds) |
||||||
|
this.logging = true; |
||||||
|
}, |
||||||
|
}) |
||||||
|
return server |
||||||
|
} |
||||||
Loading…
Reference in new issue