fix(#revert ads): revert ads #229

Merged
andrey.dekterev merged 1 commits from revert-ads into develop 3 years ago
  1. 1
      src/components/Ads/helpers/index.tsx
  2. 2
      src/components/Ads/helpers/isVideo.tsx
  3. 1
      src/config/index.tsx
  4. 1
      src/config/localStorageKeys.tsx
  5. 1
      src/config/queries.tsx
  6. 17
      src/features/HeaderFilters/components/DateFilter/hooks/index.tsx
  7. 29
      src/features/HomePage/hooks.tsx
  8. 16
      src/features/HomePage/index.tsx
  9. 1
      src/features/Matches/components/MatchesList/index.tsx
  10. 8
      src/features/MatchesGrid/styled.tsx
  11. 4
      src/features/TournamentList/components/TournamentMobile/styled.tsx
  12. 1
      src/features/TournamentList/index.tsx
  13. 9
      src/index.tsx
  14. 7
      src/pages/HighlightsPage/storeHighlightsAtoms.tsx
  15. 2
      src/requests/getAds/index.tsx
  16. 4
      src/requests/index.tsx
  17. 31
      src/utilits/mirage/Mirage.tsx
  18. 300
      src/utilits/mirage/fixtures/getAds.tsx
  19. 2
      src/utilits/mirage/fixtures/index.tsx
  20. 8
      src/utilits/mirage/models/index.tsx
  21. 44
      src/utilits/mirage/server.ts

@ -1 +0,0 @@
export * from './isVideo'

@ -1,2 +0,0 @@
const regexp = /^https?:\/\/\S+(?:mp4)$/
export const checkVideo = (url: string) => regexp.test(url)

@ -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',

@ -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) && (

@ -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;

@ -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,2 +0,0 @@
export * from './getAds'
export * from './updateAdsView'

@ -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