From 25869b83ec3e7fdff6047790e4e5907e71d88298 Mon Sep 17 00:00:00 2001 From: andreidekterev Date: Thu, 8 Jun 2023 20:16:16 +0700 Subject: [PATCH] fix(#revert ads): revert ads --- src/components/Ads/helpers/index.tsx | 1 - src/components/Ads/helpers/isVideo.tsx | 2 - src/config/index.tsx | 1 - src/config/localStorageKeys.tsx | 1 - src/config/queries.tsx | 1 - .../components/DateFilter/hooks/index.tsx | 17 +- src/features/HomePage/hooks.tsx | 29 +- src/features/HomePage/index.tsx | 16 +- .../Matches/components/MatchesList/index.tsx | 1 - src/features/MatchesGrid/styled.tsx | 8 +- .../components/TournamentMobile/styled.tsx | 4 - src/features/TournamentList/index.tsx | 1 - src/index.tsx | 9 +- .../HighlightsPage/storeHighlightsAtoms.tsx | 7 +- src/requests/getAds/index.tsx | 2 - src/requests/index.tsx | 4 - src/utilits/mirage/Mirage.tsx | 31 ++ src/utilits/mirage/fixtures/getAds.tsx | 300 ------------------ src/utilits/mirage/fixtures/index.tsx | 2 - src/utilits/mirage/models/index.tsx | 8 - src/utilits/mirage/server.ts | 44 --- 21 files changed, 45 insertions(+), 444 deletions(-) delete mode 100644 src/components/Ads/helpers/index.tsx delete mode 100644 src/components/Ads/helpers/isVideo.tsx delete mode 100644 src/config/localStorageKeys.tsx delete mode 100644 src/requests/getAds/index.tsx create mode 100644 src/utilits/mirage/Mirage.tsx delete mode 100644 src/utilits/mirage/fixtures/getAds.tsx delete mode 100644 src/utilits/mirage/fixtures/index.tsx delete mode 100644 src/utilits/mirage/models/index.tsx delete mode 100644 src/utilits/mirage/server.ts diff --git a/src/components/Ads/helpers/index.tsx b/src/components/Ads/helpers/index.tsx deleted file mode 100644 index 6be4e5f8..00000000 --- a/src/components/Ads/helpers/index.tsx +++ /dev/null @@ -1 +0,0 @@ -export * from './isVideo' diff --git a/src/components/Ads/helpers/isVideo.tsx b/src/components/Ads/helpers/isVideo.tsx deleted file mode 100644 index cb35abc1..00000000 --- a/src/components/Ads/helpers/isVideo.tsx +++ /dev/null @@ -1,2 +0,0 @@ -const regexp = /^https?:\/\/\S+(?:mp4)$/ -export const checkVideo = (url: string) => regexp.test(url) diff --git a/src/config/index.tsx b/src/config/index.tsx index cf9cf018..a5fd70ae 100644 --- a/src/config/index.tsx +++ b/src/config/index.tsx @@ -12,4 +12,3 @@ export * from './userAgent' export * from './queries' export * from './keyboardKeys' export * from './clients' -export * from './localStorageKeys' diff --git a/src/config/localStorageKeys.tsx b/src/config/localStorageKeys.tsx deleted file mode 100644 index c571f751..00000000 --- a/src/config/localStorageKeys.tsx +++ /dev/null @@ -1 +0,0 @@ -export const COUNTRY = 'COUNTRY' diff --git a/src/config/queries.tsx b/src/config/queries.tsx index 45fbda9d..79580931 100644 --- a/src/config/queries.tsx +++ b/src/config/queries.tsx @@ -1,5 +1,4 @@ export const querieKeys = { - ads: 'ads', liveMatchScores: 'liveMatchScores', matchScore: 'matchScore', sportsList: 'sportsList', diff --git a/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx b/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx index d03843af..e462d1a2 100644 --- a/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx +++ b/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx @@ -6,18 +6,16 @@ import { import addDays from 'date-fns/addDays' -import { useLocalStore, useToggle } from 'hooks' +import { useToggle } from 'hooks' import { useLexicsStore } from 'features/LexicsStore' import { useHeaderFiltersStore } from 'features/HeaderFilters' -import isObject from 'lodash/isObject' import { getDisplayDate, getWeekName, getWeeks, } from '../helpers' -import { ViewsType } from '../../../../../components/Ads/types' export const useDateFilter = () => { const { @@ -48,15 +46,6 @@ export const useDateFilter = () => { const parseFilters = filters && JSON.parse(filters) const lastDate = parseFilters?.selectedDate const weekName = getWeekName(selectedDate, 'en') - const validator = (value: unknown) => Boolean(value) && isObject(value) - - const [adsViews, setAdsViews] = useLocalStore({ - clearOnUnmount: true, - defaultValue: { HOME: 0 }, - key: 'adsViews', - validator, - }) - useEffect(() => { if (lastDate === selectedDate.getDate() && parseFilters @@ -68,10 +57,6 @@ export const useDateFilter = () => { setIsShowTournament(true) setSelectedFilters([]) setSelectedLeague(['all_competitions']) - setAdsViews({ - ...adsViews, - HOME: (adsViews.HOME ?? 0) + 1, - }) } // eslint-disable-next-line react-hooks/exhaustive-deps }, [selectedDate]) diff --git a/src/features/HomePage/hooks.tsx b/src/features/HomePage/hooks.tsx index c0a8ddaf..3bbf437d 100644 --- a/src/features/HomePage/hooks.tsx +++ b/src/features/HomePage/hooks.tsx @@ -14,19 +14,10 @@ import { ClientNames } from 'config/clients/types' import { useAuthStore } from 'features/AuthStore' import { useHeaderFiltersStore } from 'features/HeaderFilters' -import { - getHomeMatches, - getAgreements, - setAgreements, - getCountryCode, -} from 'requests' - -import { setLocalStorageItem } from 'helpers' - -import { COUNTRY } from 'config' +import { getHomeMatches } from 'requests/getMatches' +import { getAgreements, setAgreements } from 'requests/getAgreements' import { isSportFilterShownAtom } from './Atoms/HomePageAtoms' -import { useAds } from '../../components/Ads/hooks' /** * возвращает смещение в минутах относительно UTC @@ -43,27 +34,18 @@ const getTimezoneOffset = (date: Date) => { const getDate = (date: Date) => format(date, 'yyyy-MM-dd') export const useHomePage = () => { - const { userInfo } = useAuthStore() + const { user, userInfo } = useAuthStore() const { selectedDate } = useHeaderFiltersStore() const [isOpenDownload, setIsOpenDownload] = useState(false) const [isShowConfirmPopup, setIsShowConfirmPopup] = useState(false) const setIsSportFilterShown = useSetRecoilState(isSportFilterShownAtom) - const { ads } = useAds() - const handleCloseConfirmPopup = useCallback(async () => { await setAgreements(`${userInfo?.email}` || '') setIsShowConfirmPopup(false) // eslint-disable-next-line react-hooks/exhaustive-deps }, [setIsShowConfirmPopup, userInfo]) - const countryCode = async () => { - const { country_code } = await getCountryCode() - country_code && setLocalStorageItem(COUNTRY, country_code) - - return country_code - } - useEffect(() => { if (userInfo?.email) { (async () => { @@ -83,8 +65,6 @@ export const useHomePage = () => { ) { setIsOpenDownload(true) } - - countryCode() }, []) const fetchMatches = useCallback( @@ -95,7 +75,7 @@ export const useHomePage = () => { timezoneOffset: getTimezoneOffset(selectedDate), }), // eslint-disable-next-line react-hooks/exhaustive-deps - [selectedDate, userInfo?.email], + [selectedDate, user], ) useEffect(() => { @@ -105,7 +85,6 @@ export const useHomePage = () => { }, [setIsSportFilterShown]) return { - ads, fetchMatches, handleCloseConfirmPopup, isOpenDownload, diff --git a/src/features/HomePage/index.tsx b/src/features/HomePage/index.tsx index 78bb988b..f5d94791 100644 --- a/src/features/HomePage/index.tsx +++ b/src/features/HomePage/index.tsx @@ -20,13 +20,10 @@ import { useHomePage } from './hooks' import { Header } from './components/Header' import { HeaderMobile } from '../HeaderMobile' import { HeaderFilters } from './components/HeaderFilters' -import { HeaderAds } from '../../components/Ads' -import { HEADER_MOBILE_ADS } from '../../components/Ads/types' const Home = () => { usePageLogger(PAGES.home) const { - ads, fetchMatches, handleCloseConfirmPopup, isOpenDownload, @@ -49,17 +46,8 @@ const Home = () => {
- {!isMobileDevice && } - {userInfo?.email - && ads - && ( - HEADER_MOBILE_ADS.includes(position.id)) - : ads?.header - } - /> - )} + {isMobileDevice ? null : } + {/* {userInfo?.email && } */} { const Component = matchesComponents[as] - return ( {!isEmpty(matches) && ( diff --git a/src/features/MatchesGrid/styled.tsx b/src/features/MatchesGrid/styled.tsx index 1b1459a5..7bcbc34d 100644 --- a/src/features/MatchesGrid/styled.tsx +++ b/src/features/MatchesGrid/styled.tsx @@ -4,14 +4,8 @@ import { isMobileDevice } from 'config/userAgent' export const Wrapper = styled.ul` display: grid; - grid-template-columns: repeat(6, 15.6%); grid-gap: 0.9rem; - - .secondRow { - grid-column: 1 / 2; - grid-row: 2 / 3; - } - + grid-template-columns: repeat(6, 15.7%); ${isMobileDevice ? css` display: flex; diff --git a/src/features/TournamentList/components/TournamentMobile/styled.tsx b/src/features/TournamentList/components/TournamentMobile/styled.tsx index c34ba116..3a103dc1 100644 --- a/src/features/TournamentList/components/TournamentMobile/styled.tsx +++ b/src/features/TournamentList/components/TournamentMobile/styled.tsx @@ -80,10 +80,6 @@ export const ScSecondInfo = styled.div` export const ScMatchesWrapper = styled.ul` display: flex; flex-direction: column; - - .mobileAdInCell { - margin: 6px 0 0; - } ` export const ScStar = styled(Icon)` diff --git a/src/features/TournamentList/index.tsx b/src/features/TournamentList/index.tsx index fce6e108..7407d515 100644 --- a/src/features/TournamentList/index.tsx +++ b/src/features/TournamentList/index.tsx @@ -32,7 +32,6 @@ export type TournamentListProps = { export const TournamentList = ({ matches }: TournamentTypeProps) => { const { tournaments, tournamentSort } = useTournaments(matches) - const isHomePage = useRouteMatch(PAGES.home)?.isExact switch (true) { diff --git a/src/index.tsx b/src/index.tsx index 7b6e9869..32b41c61 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -5,13 +5,14 @@ import { } from 'react' import ReactDOM from 'react-dom' -import { isIOS } from 'config/userAgent' -// import { makeServer } from 'utilits/mirage/server' - import * as Sentry 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 { ENV } from './config' if (process.env.NODE_ENV !== 'development') { Sentry.init({ diff --git a/src/pages/HighlightsPage/storeHighlightsAtoms.tsx b/src/pages/HighlightsPage/storeHighlightsAtoms.tsx index 542aed44..2c0227dd 100644 --- a/src/pages/HighlightsPage/storeHighlightsAtoms.tsx +++ b/src/pages/HighlightsPage/storeHighlightsAtoms.tsx @@ -1,6 +1,6 @@ import { atom, selector } from 'recoil' -import type { AdResponse, Match } from 'requests' +import type { Match } from 'requests' export type MatchType = Match & { isChecked: boolean, @@ -43,11 +43,6 @@ export const fetchingMatches = atom({ key: 'fetchingMatches', }) -export const adsStore = atom({ - default: {} as AdResponse, - key: 'adsStore', -}) - export const checkedMatches = selector({ get: ({ get }) => { const matches = get(playerMatchesState) diff --git a/src/requests/getAds/index.tsx b/src/requests/getAds/index.tsx deleted file mode 100644 index 106b0b5a..00000000 --- a/src/requests/getAds/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from './getAds' -export * from './updateAdsView' diff --git a/src/requests/index.tsx b/src/requests/index.tsx index 412f1242..0613c71a 100644 --- a/src/requests/index.tsx +++ b/src/requests/index.tsx @@ -34,7 +34,3 @@ export * from './getMatchParticipants' export * from './getStatsEvents' export * from './getTokenVirtualUser' export * from './checkDevice' -export * from './getAds' -export * from './getFavouriteTeam' -export * from './getCountryCode' -export * from './getAgreements' diff --git a/src/utilits/mirage/Mirage.tsx b/src/utilits/mirage/Mirage.tsx new file mode 100644 index 00000000..b685e049 --- /dev/null +++ b/src/utilits/mirage/Mirage.tsx @@ -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>({}), + }, + 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 +} diff --git a/src/utilits/mirage/fixtures/getAds.tsx b/src/utilits/mirage/fixtures/getAds.tsx deleted file mode 100644 index 22342d3b..00000000 --- a/src/utilits/mirage/fixtures/getAds.tsx +++ /dev/null @@ -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 - // } - ] - } -} diff --git a/src/utilits/mirage/fixtures/index.tsx b/src/utilits/mirage/fixtures/index.tsx deleted file mode 100644 index b1fcdff4..00000000 --- a/src/utilits/mirage/fixtures/index.tsx +++ /dev/null @@ -1,2 +0,0 @@ -export * from './getAds' -export * from './surveys' diff --git a/src/utilits/mirage/models/index.tsx b/src/utilits/mirage/models/index.tsx deleted file mode 100644 index d4274eff..00000000 --- a/src/utilits/mirage/models/index.tsx +++ /dev/null @@ -1,8 +0,0 @@ -/* eslint-disable */ -import { Model } from 'miragejs' -import type { ResponseType, AdResponse } from 'requests' - -export const models = { - ads: Model.extend>({}), - surveys: Model.extend>({}), -} diff --git a/src/utilits/mirage/server.ts b/src/utilits/mirage/server.ts deleted file mode 100644 index ed3b2b49..00000000 --- a/src/utilits/mirage/server.ts +++ /dev/null @@ -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 -} -- 2.30.2