File diff suppressed because it is too large
Load Diff
@ -1,84 +0,0 @@ |
|||||||
import { useEffect, useState } from 'react' |
|
||||||
|
|
||||||
import ReactGA from 'react-ga' |
|
||||||
|
|
||||||
import { updateAdsView } from 'requests' |
|
||||||
|
|
||||||
import { useToggle } from 'hooks' |
|
||||||
|
|
||||||
import { getLocalStorageItem } from 'helpers' |
|
||||||
|
|
||||||
import { |
|
||||||
device, |
|
||||||
COUNTRY, |
|
||||||
} from 'config' |
|
||||||
|
|
||||||
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 views = getLocalStorageItem(adsViews) as ViewsType |
|
||||||
const { |
|
||||||
duration, |
|
||||||
frequency, |
|
||||||
id, |
|
||||||
media, |
|
||||||
name, |
|
||||||
time_close, |
|
||||||
} = ad |
|
||||||
|
|
||||||
const isVideo = checkVideo(media.url) |
|
||||||
|
|
||||||
const { |
|
||||||
isOpen: isOpenCloseBtn, |
|
||||||
open: showCloseBtn, |
|
||||||
} = useToggle() |
|
||||||
|
|
||||||
const handleClose = async () => { |
|
||||||
setIsOpenAd(false) |
|
||||||
await updateAdsView({ adv_id: id }) |
|
||||||
sendBannerClickEvent(EventGA.CLOSE) |
|
||||||
} |
|
||||||
|
|
||||||
const sendBannerClickEvent = (event: EventGA) => { |
|
||||||
ReactGA.event({ |
|
||||||
action: event, |
|
||||||
category: 'Advertisement', |
|
||||||
label: `${name}_${countryCode ?? ''}_${device}`, |
|
||||||
value: id, |
|
||||||
}) |
|
||||||
} |
|
||||||
|
|
||||||
const isNeedToShow = Number(views?.HOME) % frequency === 0 |
|
||||||
|
|
||||||
useEffect(() => { |
|
||||||
!isNeedToShow && setIsOpenAd(false) |
|
||||||
|
|
||||||
const timeoutCloseAd = setTimeout(handleClose, duration * 1000) |
|
||||||
const timeoutCloseBtn = time_close && setTimeout(showCloseBtn, time_close * 1000) |
|
||||||
|
|
||||||
return () => { |
|
||||||
time_close && clearTimeout(timeoutCloseBtn) |
|
||||||
clearTimeout(timeoutCloseAd) |
|
||||||
} |
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
||||||
}, []) |
|
||||||
|
|
||||||
return { |
|
||||||
handleClose, |
|
||||||
isNeedToShow, |
|
||||||
isOpenAd, |
|
||||||
isOpenCloseBtn, |
|
||||||
isVideo, |
|
||||||
sendBannerClickEvent, |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,77 +0,0 @@ |
|||||||
import { memo, MouseEvent } from 'react' |
|
||||||
|
|
||||||
import type { AdType } from 'requests' |
|
||||||
|
|
||||||
import { |
|
||||||
AdImg, |
|
||||||
AdVideo, |
|
||||||
AdWrapper, |
|
||||||
} from './styled' |
|
||||||
import { useAd } from './hooks' |
|
||||||
|
|
||||||
import { EventGA } from '../../types' |
|
||||||
import { CloseButton } from '../../../../features/PopupComponents' |
|
||||||
|
|
||||||
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 }) |
|
||||||
|
|
||||||
return ( |
|
||||||
position && isOpenAd && isNeedToShow |
|
||||||
? ( |
|
||||||
<AdWrapper |
|
||||||
position={position.id} |
|
||||||
isOpenAd={isOpenAd} |
|
||||||
> |
|
||||||
{isOpenCloseBtn && ( |
|
||||||
<CloseButton |
|
||||||
onClick={(e: MouseEvent<HTMLButtonElement>) => { |
|
||||||
e.stopPropagation() |
|
||||||
handleClose() |
|
||||||
}} |
|
||||||
size={12} |
|
||||||
className='closeBtn' |
|
||||||
/> |
|
||||||
)} |
|
||||||
<a |
|
||||||
href={link} |
|
||||||
target='_blank' |
|
||||||
rel='noreferrer' |
|
||||||
onClick={() => link && sendBannerClickEvent(EventGA.CLICK)} |
|
||||||
> |
|
||||||
{isVideo |
|
||||||
? ( |
|
||||||
<AdVideo |
|
||||||
muted={isVideo} |
|
||||||
autoPlay={isVideo} |
|
||||||
loop={isVideo} |
|
||||||
src={media.url} |
|
||||||
position={position.id} |
|
||||||
/> |
|
||||||
) |
|
||||||
: ( |
|
||||||
<AdImg |
|
||||||
src={media.url} |
|
||||||
position={position.id} |
|
||||||
/> |
|
||||||
)} |
|
||||||
</a> |
|
||||||
</AdWrapper> |
|
||||||
) : null |
|
||||||
) |
|
||||||
}) |
|
||||||
@ -1,63 +0,0 @@ |
|||||||
import styled from 'styled-components/macro' |
|
||||||
import { VIEW_ADS } from '../../types' |
|
||||||
|
|
||||||
type Props = { |
|
||||||
position: number, |
|
||||||
} |
|
||||||
|
|
||||||
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;' |
|
||||||
default: |
|
||||||
return '' |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
const header = [7, 8, 9] |
|
||||||
|
|
||||||
export const AdImg = styled.img<Props>` |
|
||||||
object-fit: cover; |
|
||||||
width: 100%; |
|
||||||
min-height: ${({ position }) => (!header.includes(position) && '100%')}; |
|
||||||
max-height: ${({ position }) => (header.includes(position) ? '13rem' : '100%')}; |
|
||||||
cursor: pointer; |
|
||||||
border-radius: 3px; |
|
||||||
` |
|
||||||
|
|
||||||
export const AdVideo = styled.video<Props>` |
|
||||||
object-fit: contain; |
|
||||||
width: 100%; |
|
||||||
cursor: pointer; |
|
||||||
max-height: ${({ position }) => (header.includes(position) ? '283px' : '100%')}; |
|
||||||
background-color: black; |
|
||||||
border-radius: 3px; |
|
||||||
` |
|
||||||
|
|
||||||
export const AdWrapper = styled.div<Props & {isOpenAd: boolean}>` |
|
||||||
position: relative; |
|
||||||
width: 100%; |
|
||||||
height: 100%; |
|
||||||
|
|
||||||
${({ position }) => chooseStyle(position)}; |
|
||||||
|
|
||||||
display: ${({ isOpenAd }) => (isOpenAd ? '' : 'none')}; |
|
||||||
|
|
||||||
.closeBtn { |
|
||||||
position: absolute; |
|
||||||
right: 0; |
|
||||||
top: 0; |
|
||||||
background: none; |
|
||||||
border-radius: 0; |
|
||||||
z-index: 2; |
|
||||||
cursor: pointer; |
|
||||||
} |
|
||||||
` |
|
||||||
@ -1,69 +0,0 @@ |
|||||||
import type { MouseEvent } from 'react' |
|
||||||
|
|
||||||
import type { AdType } from 'requests' |
|
||||||
|
|
||||||
import { CloseButton } from 'features/PopupComponents' |
|
||||||
import { |
|
||||||
Img, |
|
||||||
MobileAdWrapper, |
|
||||||
Video, |
|
||||||
} from './styled' |
|
||||||
|
|
||||||
import { useAd } from '../AdComponent/hooks' |
|
||||||
import { EventGA } from '../../types' |
|
||||||
|
|
||||||
type MobileAdTypes = { |
|
||||||
ad: AdType, |
|
||||||
className?: string, |
|
||||||
} |
|
||||||
|
|
||||||
export const MobileAd = ({ |
|
||||||
ad, |
|
||||||
className, |
|
||||||
}: MobileAdTypes) => { |
|
||||||
const { |
|
||||||
link, |
|
||||||
media, |
|
||||||
position, |
|
||||||
} = ad |
|
||||||
|
|
||||||
const { |
|
||||||
handleClose, |
|
||||||
isNeedToShow, |
|
||||||
isOpenAd, |
|
||||||
isOpenCloseBtn, |
|
||||||
isVideo, |
|
||||||
sendBannerClickEvent, |
|
||||||
} = useAd({ ad }) |
|
||||||
|
|
||||||
return ( |
|
||||||
position && isOpenAd && isNeedToShow ? ( |
|
||||||
<MobileAdWrapper |
|
||||||
className={className} |
|
||||||
onClick={() => { |
|
||||||
if (link) { |
|
||||||
sendBannerClickEvent(EventGA.CLICK) |
|
||||||
window.open(link, '_blank') |
|
||||||
} |
|
||||||
}} |
|
||||||
> |
|
||||||
{isOpenCloseBtn |
|
||||||
&& ( |
|
||||||
<CloseButton |
|
||||||
onClick={(e: MouseEvent<HTMLButtonElement>) => { |
|
||||||
e.stopPropagation() |
|
||||||
handleClose() |
|
||||||
}} |
|
||||||
size={8} |
|
||||||
className='mobileCloseBtn' |
|
||||||
/> |
|
||||||
)} |
|
||||||
{isVideo |
|
||||||
? <Video position={position.id} src={media.url} /> |
|
||||||
: ( |
|
||||||
<Img position={position.id} src={media.url} /> |
|
||||||
)} |
|
||||||
</MobileAdWrapper> |
|
||||||
) : null |
|
||||||
) |
|
||||||
} |
|
||||||
@ -1,35 +0,0 @@ |
|||||||
import styled from 'styled-components/macro' |
|
||||||
|
|
||||||
type Props = { |
|
||||||
position: number, |
|
||||||
} |
|
||||||
|
|
||||||
export const MobileAdWrapper = styled.div` |
|
||||||
position: relative; |
|
||||||
width: 100%; |
|
||||||
|
|
||||||
.mobileCloseBtn{ |
|
||||||
position: absolute; |
|
||||||
right: -10px; |
|
||||||
background: none; |
|
||||||
border-radius: 0; |
|
||||||
color: rgba(0, 0, 0, 0.6); |
|
||||||
top: 10px; |
|
||||||
transform: translate(-50%, -50%); |
|
||||||
z-index: 2; |
|
||||||
} |
|
||||||
` |
|
||||||
export const Img = styled.img<Props>` |
|
||||||
object-fit: cover; |
|
||||||
height: ${({ position }) => (position === 10 ? '50px' : '75px')}; |
|
||||||
border-radius: 2px; |
|
||||||
width: 100%; |
|
||||||
` |
|
||||||
|
|
||||||
export const Video = styled.video<Props>` |
|
||||||
max-height: 100%; |
|
||||||
object-fit: cover; |
|
||||||
min-width: 100%; |
|
||||||
height: ${({ position }) => (position === 10 ? '50px' : '75px')}; |
|
||||||
border-radius: 2px; |
|
||||||
` |
|
||||||
@ -1,16 +0,0 @@ |
|||||||
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 |
|
||||||
} |
|
||||||
@ -1 +0,0 @@ |
|||||||
export * from './isVideo' |
|
||||||
@ -1,2 +0,0 @@ |
|||||||
const regexp = /^https?:\/\/\S+(?:mp4)$/ |
|
||||||
export const checkVideo = (url: string) => regexp.test(url) |
|
||||||
@ -1,47 +0,0 @@ |
|||||||
import { useMemo } from 'react' |
|
||||||
|
|
||||||
import { useQuery } from 'react-query' |
|
||||||
|
|
||||||
import { useRecoilState } from 'recoil' |
|
||||||
|
|
||||||
import { isMobileDevice, querieKeys } from 'config' |
|
||||||
|
|
||||||
import { getAds } from 'requests' |
|
||||||
|
|
||||||
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' |
|
||||||
|
|
||||||
export const useAds = () => { |
|
||||||
const [ads, setAds] = useRecoilState(adsStore) |
|
||||||
const { lang } = useLang() |
|
||||||
const { user } = useAuthStore() |
|
||||||
|
|
||||||
useQuery({ |
|
||||||
queryFn: async () => { |
|
||||||
if (user) { |
|
||||||
const adsList = await getAds({ |
|
||||||
client_type: isMobileDevice ? DeviceType.MOBILE : DeviceType.WEB, |
|
||||||
language: lang, |
|
||||||
type_id: PageType.HOME, |
|
||||||
}) |
|
||||||
adsList && setAds(adsList) |
|
||||||
return adsList |
|
||||||
} |
|
||||||
return {} |
|
||||||
}, |
|
||||||
queryKey: querieKeys.ads, |
|
||||||
staleTime: useMemo(() => Math.max(calcMaxAdDurationAds(ads), 60 * 1000), [ads]), |
|
||||||
}) |
|
||||||
|
|
||||||
return { |
|
||||||
ads, |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,31 +0,0 @@ |
|||||||
import type { AdType } from 'requests' |
|
||||||
|
|
||||||
import { isMobileDevice } from 'config' |
|
||||||
|
|
||||||
import { |
|
||||||
HeaderWrapAd, |
|
||||||
} from './styled' |
|
||||||
|
|
||||||
import { AdComponent } from './components/AdComponent' |
|
||||||
import { AdsPropsType } from './types' |
|
||||||
import { MobileAd } from './components/MobileAd' |
|
||||||
|
|
||||||
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 |
|
||||||
) |
|
||||||
@ -1,16 +0,0 @@ |
|||||||
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: 0px 0.71rem; |
|
||||||
grid-template-columns: none; |
|
||||||
`}}
|
|
||||||
` |
|
||||||
@ -1,34 +0,0 @@ |
|||||||
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' |
|
||||||
} |
|
||||||
|
|
||||||
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 type AdsPropsType = Record<'ads', AdsListType | undefined> |
|
||||||
|
|
||||||
export const adsViews = 'adsViews' |
|
||||||
@ -1 +0,0 @@ |
|||||||
export const COUNTRY = 'COUNTRY' |
|
||||||
@ -1,8 +1,5 @@ |
|||||||
export const device = navigator.userAgent |
export const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) |
||||||
|
|
||||||
export const isIOS = /iPad|iPhone|iPod/.test(device) |
export const isAndroid = /Android/.test(navigator.userAgent) |
||||||
|
|
||||||
export const isAndroid = /Android/.test(device) |
|
||||||
|
|
||||||
export const isMobileDevice = /iPhone|Android/.test(device) |
|
||||||
|
|
||||||
|
export const isMobileDevice = /iPhone|Android/.test(navigator.userAgent) |
||||||
|
|||||||
@ -1,52 +0,0 @@ |
|||||||
import { callApi } from 'helpers' |
|
||||||
|
|
||||||
import { ADS_API_URL } from 'config' |
|
||||||
import { DeviceType } from '../../components/Ads/types' |
|
||||||
|
|
||||||
export type AdsParams = { |
|
||||||
client_type: DeviceType, |
|
||||||
language: string, |
|
||||||
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' |
|
||||||
|
|
||||||
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, |
|
||||||
}) |
|
||||||
} |
|
||||||
@ -1,2 +0,0 @@ |
|||||||
export * from './getAds' |
|
||||||
export * from './updateAdsView' |
|
||||||
@ -1,29 +0,0 @@ |
|||||||
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' | '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`, |
|
||||||
}) |
|
||||||
} |
|
||||||
@ -0,0 +1,31 @@ |
|||||||
|
/* 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 |
||||||
|
} |
||||||
@ -1,300 +0,0 @@ |
|||||||
/* 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 |
|
||||||
} |
|
||||||
], |
|
||||||
"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": 120,
|
|
||||||
// "time_close": null,
|
|
||||||
// "media": {
|
|
||||||
// "url": "https://cf-aws-staging.insports.tv/media/folder/74/en/web.png"
|
|
||||||
// },
|
|
||||||
// "remaining_views": 9
|
|
||||||
// }
|
|
||||||
] |
|
||||||
} |
|
||||||
} |
|
||||||
@ -1,2 +0,0 @@ |
|||||||
export * from './getAds' |
|
||||||
export * from './surveys' |
|
||||||
@ -1,8 +0,0 @@ |
|||||||
/* 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>>({}), |
|
||||||
} |
|
||||||
@ -1,44 +0,0 @@ |
|||||||
/* 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