Revert "add ads to main page"

This reverts commit 4129e2730a.
pull/230/head
andreidekterev 3 years ago
parent 475126d2dc
commit 09e49d4e19
  1. 35261
      package-lock.json
  2. 1
      package.json
  3. 84
      src/components/Ads/components/AdComponent/hooks.tsx
  4. 78
      src/components/Ads/components/AdComponent/index.tsx
  5. 63
      src/components/Ads/components/AdComponent/styled.tsx
  6. 69
      src/components/Ads/components/MobileAd/index.tsx
  7. 35
      src/components/Ads/components/MobileAd/styled.tsx
  8. 16
      src/components/Ads/helpers/calcMaxDurationAds.tsx
  9. 1
      src/components/Ads/helpers/index.tsx
  10. 2
      src/components/Ads/helpers/isVideo.tsx
  11. 44
      src/components/Ads/hooks.tsx
  12. 30
      src/components/Ads/index.tsx
  13. 15
      src/components/Ads/styled.tsx
  14. 37
      src/components/Ads/types.tsx
  15. 1
      src/config/index.tsx
  16. 1
      src/config/localStorageKeys.tsx
  17. 1
      src/config/queries.tsx
  18. 2
      src/config/userAgent.tsx
  19. 17
      src/features/HeaderFilters/components/DateFilter/hooks/index.tsx
  20. 29
      src/features/HomePage/hooks.tsx
  21. 16
      src/features/HomePage/index.tsx
  22. 1
      src/features/Matches/components/MatchesList/index.tsx
  23. 19
      src/features/MatchesGrid/index.tsx
  24. 8
      src/features/MatchesGrid/styled.tsx
  25. 39
      src/features/TournamentList/components/TournamentMobile/index.tsx
  26. 4
      src/features/TournamentList/components/TournamentMobile/styled.tsx
  27. 1
      src/features/TournamentList/index.tsx
  28. 9
      src/index.tsx
  29. 7
      src/pages/HighlightsPage/storeHighlightsAtoms.tsx
  30. 52
      src/requests/getAds/getAds.tsx
  31. 2
      src/requests/getAds/index.tsx
  32. 29
      src/requests/getAds/updateAdsView.tsx
  33. 4
      src/requests/index.tsx
  34. 31
      src/utilits/mirage/Mirage.tsx
  35. 300
      src/utilits/mirage/fixtures/getAds.tsx
  36. 2
      src/utilits/mirage/fixtures/index.tsx
  37. 8
      src/utilits/mirage/models/index.tsx
  38. 44
      src/utilits/mirage/server.ts

35261
package-lock.json generated

File diff suppressed because it is too large Load Diff

@ -38,7 +38,6 @@
"react": "^17.0.2", "react": "^17.0.2",
"react-datepicker": "^3.1.3", "react-datepicker": "^3.1.3",
"react-dom": "^17.0.2", "react-dom": "^17.0.2",
"react-ga": "^3.3.1",
"react-query": "^3.39.3", "react-query": "^3.39.3",
"react-router": "^5.2.0", "react-router": "^5.2.0",
"react-router-dom": "^5.2.0", "react-router-dom": "^5.2.0",

@ -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, close: hideElement }: 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,78 +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,
close?: () => void,
}
export const AdComponent = memo(({ ad, close }: AdComponentType) => {
const {
link,
media,
position,
} = ad
const {
handleClose,
isNeedToShow,
isOpenAd,
isOpenCloseBtn,
isVideo,
sendBannerClickEvent,
} = useAd({ ad, close })
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'
import { VIEW_ADS } from '../../types'
type Props = {
position: number,
}
const chooseStyle = (type: number) => {
switch (true) {
case VIEW_ADS[type] === 'COLUMN':
return 'grid-row: 1 / 3; img {max-height: none;}'
case VIEW_ADS[type] === 'ROW':
return 'grid-column: 1 / 3'
case VIEW_ADS[type] === 'SQUARE':
return 'grid-row: 1 / 3; grid-column: 1 / 3; img {max-height: none;}'
case VIEW_ADS[type] === 'SECOND_COLUMN':
return 'grid-column: 2 / 3; grid-row: 1 / 1'
case VIEW_ADS[type] === 'SECOND_ROW':
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 { 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,
close?: () => void,
}
export const MobileAd = ({
ad,
className,
close,
}: MobileAdTypes) => {
const {
link,
media,
position,
} = ad
const {
handleClose,
isNeedToShow,
isOpenAd,
isOpenCloseBtn,
isVideo,
sendBannerClickEvent,
} = useAd({ ad, close })
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'
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 { 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,44 +0,0 @@
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 { useMemo } from 'react'
import {
DeviceType,
PageType,
} from './types'
import { calcMaxAdDurationAds } from './helpers/calcMaxDurationAds'
import { useAuthStore } from '../../features/AuthStore'
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,30 +0,0 @@
import type { AdType } from 'requests'
import {
HeaderWrapAd,
} from './styled'
import { AdComponent } from './components/AdComponent'
import { AdsPropsType } from './types'
import { MobileAd } from './components/MobileAd'
import { isMobileDevice } from '../../config'
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,15 +0,0 @@
import styled, { css } from 'styled-components'
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,37 +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,
HEADER_1 = 7,
HEADER_2 = 8,
HEADER_LONG = 9,
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'

@ -12,4 +12,3 @@ export * from './userAgent'
export * from './queries' export * from './queries'
export * from './keyboardKeys' export * from './keyboardKeys'
export * from './clients' export * from './clients'
export * from './localStorageKeys'

@ -1 +0,0 @@
export const COUNTRY = 'COUNTRY'

@ -1,5 +1,4 @@
export const querieKeys = { export const querieKeys = {
ads: 'ads',
liveMatchScores: 'liveMatchScores', liveMatchScores: 'liveMatchScores',
matchScore: 'matchScore', matchScore: 'matchScore',
sportsList: 'sportsList', sportsList: 'sportsList',

@ -3,5 +3,3 @@ export const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent)
export const isAndroid = /Android/.test(navigator.userAgent) export const isAndroid = /Android/.test(navigator.userAgent)
export const isMobileDevice = /iPhone|Android/.test(navigator.userAgent) export const isMobileDevice = /iPhone|Android/.test(navigator.userAgent)
export const device = navigator.userAgent

@ -6,18 +6,16 @@ import {
import addDays from 'date-fns/addDays' import addDays from 'date-fns/addDays'
import { useLocalStore, useToggle } from 'hooks' import { useToggle } from 'hooks'
import { useLexicsStore } from 'features/LexicsStore' import { useLexicsStore } from 'features/LexicsStore'
import { useHeaderFiltersStore } from 'features/HeaderFilters' import { useHeaderFiltersStore } from 'features/HeaderFilters'
import isObject from 'lodash/isObject'
import { import {
getDisplayDate, getDisplayDate,
getWeekName, getWeekName,
getWeeks, getWeeks,
} from '../helpers' } from '../helpers'
import { ViewsType } from '../../../../../components/Ads/types'
export const useDateFilter = () => { export const useDateFilter = () => {
const { const {
@ -48,15 +46,6 @@ export const useDateFilter = () => {
const parseFilters = filters && JSON.parse(filters) const parseFilters = filters && JSON.parse(filters)
const lastDate = parseFilters?.selectedDate const lastDate = parseFilters?.selectedDate
const weekName = getWeekName(selectedDate, 'en') const weekName = getWeekName(selectedDate, 'en')
const validator = (value: unknown) => Boolean(value) && isObject(value)
const [adsViews, setAdsViews] = useLocalStore<ViewsType>({
clearOnUnmount: true,
defaultValue: { HOME: 0 },
key: 'adsViews',
validator,
})
useEffect(() => { useEffect(() => {
if (lastDate === selectedDate.getDate() if (lastDate === selectedDate.getDate()
&& parseFilters && parseFilters
@ -68,10 +57,6 @@ export const useDateFilter = () => {
setIsShowTournament(true) setIsShowTournament(true)
setSelectedFilters([]) setSelectedFilters([])
setSelectedLeague(['all_competitions']) setSelectedLeague(['all_competitions'])
setAdsViews({
...adsViews,
HOME: (adsViews.HOME ?? 0) + 1,
})
} }
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [selectedDate]) }, [selectedDate])

@ -14,19 +14,10 @@ import { ClientNames } from 'config/clients/types'
import { useAuthStore } from 'features/AuthStore' import { useAuthStore } from 'features/AuthStore'
import { useHeaderFiltersStore } from 'features/HeaderFilters' import { useHeaderFiltersStore } from 'features/HeaderFilters'
import { import { getHomeMatches } from 'requests/getMatches'
getHomeMatches, import { getAgreements, setAgreements } from 'requests/getAgreements'
getAgreements,
setAgreements,
getCountryCode,
} from 'requests'
import { setLocalStorageItem } from 'helpers'
import { COUNTRY } from 'config'
import { isSportFilterShownAtom } from './Atoms/HomePageAtoms' import { isSportFilterShownAtom } from './Atoms/HomePageAtoms'
import { useAds } from '../../components/Ads/hooks'
/** /**
* возвращает смещение в минутах относительно UTC * возвращает смещение в минутах относительно UTC
@ -43,27 +34,18 @@ const getTimezoneOffset = (date: Date) => {
const getDate = (date: Date) => format(date, 'yyyy-MM-dd') const getDate = (date: Date) => format(date, 'yyyy-MM-dd')
export const useHomePage = () => { export const useHomePage = () => {
const { userInfo } = useAuthStore() const { user, userInfo } = useAuthStore()
const { selectedDate } = useHeaderFiltersStore() const { selectedDate } = useHeaderFiltersStore()
const [isOpenDownload, setIsOpenDownload] = useState(false) const [isOpenDownload, setIsOpenDownload] = useState(false)
const [isShowConfirmPopup, setIsShowConfirmPopup] = useState(false) const [isShowConfirmPopup, setIsShowConfirmPopup] = useState(false)
const setIsSportFilterShown = useSetRecoilState(isSportFilterShownAtom) const setIsSportFilterShown = useSetRecoilState(isSportFilterShownAtom)
const { ads } = useAds()
const handleCloseConfirmPopup = useCallback(async () => { const handleCloseConfirmPopup = useCallback(async () => {
await setAgreements(`${userInfo?.email}` || '') await setAgreements(`${userInfo?.email}` || '')
setIsShowConfirmPopup(false) setIsShowConfirmPopup(false)
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
}, [setIsShowConfirmPopup, userInfo]) }, [setIsShowConfirmPopup, userInfo])
const countryCode = async () => {
const { country_code } = await getCountryCode()
country_code && setLocalStorageItem(COUNTRY, country_code)
return country_code
}
useEffect(() => { useEffect(() => {
if (userInfo?.email) { if (userInfo?.email) {
(async () => { (async () => {
@ -83,8 +65,6 @@ export const useHomePage = () => {
) { ) {
setIsOpenDownload(true) setIsOpenDownload(true)
} }
countryCode()
}, []) }, [])
const fetchMatches = useCallback( const fetchMatches = useCallback(
@ -95,7 +75,7 @@ export const useHomePage = () => {
timezoneOffset: getTimezoneOffset(selectedDate), timezoneOffset: getTimezoneOffset(selectedDate),
}), }),
// eslint-disable-next-line react-hooks/exhaustive-deps // eslint-disable-next-line react-hooks/exhaustive-deps
[selectedDate, userInfo?.email], [selectedDate, user],
) )
useEffect(() => { useEffect(() => {
@ -105,7 +85,6 @@ export const useHomePage = () => {
}, [setIsSportFilterShown]) }, [setIsSportFilterShown])
return { return {
ads,
fetchMatches, fetchMatches,
handleCloseConfirmPopup, handleCloseConfirmPopup,
isOpenDownload, isOpenDownload,

@ -20,13 +20,10 @@ import { useHomePage } from './hooks'
import { Header } from './components/Header' import { Header } from './components/Header'
import { HeaderMobile } from '../HeaderMobile' import { HeaderMobile } from '../HeaderMobile'
import { HeaderFilters } from './components/HeaderFilters' import { HeaderFilters } from './components/HeaderFilters'
import { HeaderAds } from '../../components/Ads'
import { HEADER_MOBILE_ADS } from '../../components/Ads/types'
const Home = () => { const Home = () => {
usePageLogger(PAGES.home) usePageLogger(PAGES.home)
const { const {
ads,
fetchMatches, fetchMatches,
handleCloseConfirmPopup, handleCloseConfirmPopup,
isOpenDownload, isOpenDownload,
@ -49,17 +46,8 @@ const Home = () => {
<Main> <Main>
<UserFavorites /> <UserFavorites />
<Content> <Content>
{!isMobileDevice && <HeaderFilters />} {isMobileDevice ? null : <HeaderFilters />}
{userInfo?.email {/* {userInfo?.email && <Matches fetch={fetchMatches} />} */}
&& ads
&& (
<HeaderAds ads={
isMobileDevice
? ads?.mobile?.filter(({ position }) => HEADER_MOBILE_ADS.includes(position.id))
: ads?.header
}
/>
)}
<Matches fetch={fetchMatches} /> <Matches fetch={fetchMatches} />
<ConfirmPopup <ConfirmPopup
isModalOpen={isShowConfirmPopup} isModalOpen={isShowConfirmPopup}

@ -28,7 +28,6 @@ export const MatchesList = ({
title, title,
}: Props) => { }: Props) => {
const Component = matchesComponents[as] const Component = matchesComponents[as]
return ( return (
<Fragment> <Fragment>
{!isEmpty(matches) && ( {!isEmpty(matches) && (

@ -2,9 +2,9 @@ import { memo, useEffect } from 'react'
import { useRouteMatch } from 'react-router-dom' import { useRouteMatch } from 'react-router-dom'
import { useQuery } from 'react-query' import { useQuery } from 'react-query'
import { isMobileDevice, PAGES } from 'config' import { PAGES } from 'config/pages'
import type { AdType, LiveScore } from 'requests' import type { LiveScore } from 'requests'
import { getLiveScores } from 'requests' import { getLiveScores } from 'requests'
import { MatchCard } from 'features/MatchCard' import { MatchCard } from 'features/MatchCard'
@ -12,14 +12,9 @@ import { TournamentList } from 'features/TournamentList'
import type { Match } from 'features/Matches' import type { Match } from 'features/Matches'
import { useHeaderFiltersStore } from 'features/HeaderFilters' import { useHeaderFiltersStore } from 'features/HeaderFilters'
import { readToken } from 'helpers'
import { useRecoilValue } from 'recoil'
import { Wrapper } from './styled' import { Wrapper } from './styled'
import { useMatchSwitchesStore } from '../MatchSwitches' import { useMatchSwitchesStore } from '../MatchSwitches'
import { querieKeys } from '../../config' import { querieKeys } from '../../config'
import { AdComponent } from '../../components/Ads/components/AdComponent'
import { adsStore } from '../../pages/HighlightsPage/storeHighlightsAtoms'
type MatchesGridProps = { type MatchesGridProps = {
matches: Array<Match>, matches: Array<Match>,
@ -29,10 +24,6 @@ export const MatchesGrid = memo(({ matches }: MatchesGridProps) => {
const isHomePage = useRouteMatch(PAGES.home)?.isExact const isHomePage = useRouteMatch(PAGES.home)?.isExact
const { isScoreHidden } = useMatchSwitchesStore() const { isScoreHidden } = useMatchSwitchesStore()
const ads = useRecoilValue(adsStore)
const currentAds = ads?.match_cell?.length ? ads?.match_cell : ads?.block
const { const {
compareSport, compareSport,
isShowTournament, isShowTournament,
@ -85,12 +76,6 @@ export const MatchesGrid = memo(({ matches }: MatchesGridProps) => {
return ( return (
<Wrapper> <Wrapper>
{!isMobileDevice
&& readToken()
&& currentAds
&& (
currentAds?.map((ad: AdType) => <AdComponent ad={ad} />)
)}
{isHomePage && isShowTournament ? ( {isHomePage && isShowTournament ? (
<TournamentList matches={filteredMatches()} /> <TournamentList matches={filteredMatches()} />
) : ( ) : (

@ -4,14 +4,8 @@ import { isMobileDevice } from 'config/userAgent'
export const Wrapper = styled.ul` export const Wrapper = styled.ul`
display: grid; display: grid;
grid-template-columns: repeat(6, 15.6%);
grid-gap: 0.9rem; grid-gap: 0.9rem;
grid-template-columns: repeat(6, 15.7%);
.secondRow {
grid-column: 1 / 2;
grid-row: 2 / 3;
}
${isMobileDevice ${isMobileDevice
? css` ? css`
display: flex; display: flex;

@ -1,10 +1,7 @@
import { Fragment, useState } from 'react' import { Fragment, useState } from 'react'
import { isLffClient } from 'config/clients' import { isLffClient } from 'config/clients'
import { import { URL_AWS } from 'config'
isMobileDevice,
URL_AWS,
} from 'config'
import { SportIcon } from 'components/SportIcon/SportIcon' import { SportIcon } from 'components/SportIcon/SportIcon'
import { T9n } from 'features/T9n' import { T9n } from 'features/T9n'
@ -17,8 +14,6 @@ import {
LiveSign, LiveSign,
} from 'features/MatchCard/CardFrontside/MatchCardMobile/styled' } from 'features/MatchCard/CardFrontside/MatchCardMobile/styled'
import { AdType } from 'requests'
import { useRecoilValue } from 'recoil'
import { import {
CardWrapperOuter, CardWrapperOuter,
CardWrapper, CardWrapper,
@ -30,9 +25,6 @@ import {
} from './styled' } from './styled'
import { TournamentProps } from '../..' import { TournamentProps } from '../..'
import { VIEW_ADS } from '../../../../components/Ads/types'
import { MobileAd } from '../../../../components/Ads/components/MobileAd'
import { adsStore } from '../../../../pages/HighlightsPage/storeHighlightsAtoms'
export const TournamentMobile = ({ export const TournamentMobile = ({
tournament, tournament,
@ -48,8 +40,6 @@ export const TournamentMobile = ({
const currentColor = open ? '#ffffff' : 'rgba(255, 255, 255, 0.5)' const currentColor = open ? '#ffffff' : 'rgba(255, 255, 255, 0.5)'
const ads = useRecoilValue(adsStore)
return ( return (
<CardWrapperOuter> <CardWrapperOuter>
<CardWrapper <CardWrapper
@ -85,29 +75,10 @@ export const TournamentMobile = ({
</ScSecondInfo> </ScSecondInfo>
</CardWrapper> </CardWrapper>
<ScMatchesWrapper> <ScMatchesWrapper>
{open && ( {open
<> && tournamentMatches?.map((match: Match) => (
{isMobileDevice && ads?.mobile?.map((ad: AdType) => ( <MatchCard key={match.id} match={match} />
ad.position.id === VIEW_ADS.MOBILE_IN_COLLAPSE_HEADER && ( ))}
<MobileAd
ad={ad}
key={ad.id}
className='mobileAdInCell'
/>
)))}
{tournamentMatches?.map((match: Match) => (
<MatchCard key={match.id} match={match} />
))}
{isMobileDevice && ads?.mobile?.map((ad: AdType) => (
ad.position.id === VIEW_ADS.MOBILE_IN_COLLAPSE_FOOTER && (
<MobileAd
ad={ad}
key={ad.id}
className='mobileAdInCell'
/>
)))}
</>
)}
</ScMatchesWrapper> </ScMatchesWrapper>
</CardWrapperOuter> </CardWrapperOuter>
) )

@ -80,10 +80,6 @@ export const ScSecondInfo = styled.div`
export const ScMatchesWrapper = styled.ul` export const ScMatchesWrapper = styled.ul`
display: flex; display: flex;
flex-direction: column; flex-direction: column;
.mobileAdInCell {
margin: 6px 0 0;
}
` `
export const ScStar = styled(Icon)` export const ScStar = styled(Icon)`

@ -32,7 +32,6 @@ export type TournamentListProps = {
export const TournamentList = ({ matches }: TournamentTypeProps) => { export const TournamentList = ({ matches }: TournamentTypeProps) => {
const { tournaments, tournamentSort } = useTournaments(matches) const { tournaments, tournamentSort } = useTournaments(matches)
const isHomePage = useRouteMatch(PAGES.home)?.isExact const isHomePage = useRouteMatch(PAGES.home)?.isExact
switch (true) { switch (true) {

@ -5,13 +5,14 @@ import {
} from 'react' } from 'react'
import ReactDOM from 'react-dom' import ReactDOM from 'react-dom'
import { isIOS } from 'config/userAgent'
// import { makeServer } from 'utilits/mirage/server'
import * as Sentry from '@sentry/react' import * as Sentry from '@sentry/react'
import { BrowserTracing } from '@sentry/react' import { BrowserTracing } from '@sentry/react'
import { isIOS, ENV } from 'config'
// import { makeServer } from 'utilits/mirage/Mirage'
import * as serviceWorker from './serviceWorker' import * as serviceWorker from './serviceWorker'
import { ENV } from './config'
if (process.env.NODE_ENV !== 'development') { if (process.env.NODE_ENV !== 'development') {
Sentry.init({ Sentry.init({

@ -1,6 +1,6 @@
import { atom, selector } from 'recoil' import { atom, selector } from 'recoil'
import type { AdResponse, Match } from 'requests' import type { Match } from 'requests'
export type MatchType = Match & { export type MatchType = Match & {
isChecked: boolean, isChecked: boolean,
@ -43,11 +43,6 @@ export const fetchingMatches = atom({
key: 'fetchingMatches', key: 'fetchingMatches',
}) })
export const adsStore = atom({
default: {} as AdResponse,
key: 'adsStore',
})
export const checkedMatches = selector({ export const checkedMatches = selector({
get: ({ get }) => { get: ({ get }) => {
const matches = get(playerMatchesState) const matches = get(playerMatchesState)

@ -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`,
})
}

@ -34,7 +34,3 @@ export * from './getMatchParticipants'
export * from './getStatsEvents' export * from './getStatsEvents'
export * from './getTokenVirtualUser' export * from './getTokenVirtualUser'
export * from './checkDevice' export * from './checkDevice'
export * from './getAds'
export * from './getFavouriteTeam'
export * from './getCountryCode'
export * from './getAgreements'

@ -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…
Cancel
Save