From 36fe1fff0371ad7b8f47252e55103afd9631d553 Mon Sep 17 00:00:00 2001 From: andreidekterev Date: Thu, 8 Jun 2023 20:48:15 +0700 Subject: [PATCH] Revert "fix(#564): fix styles ads ads types" This reverts commit e188c32fcdbd07ef6430a4098844c1d7cd273839. --- .../Ads/components/AdComponent/styled.tsx | 12 +++---- .../Ads/components/MobileAd/index.tsx | 10 +++--- .../Ads/components/MobileAd/styled.tsx | 2 +- .../Ads/helpers/calcMaxDurationAds.tsx | 2 +- src/components/Ads/hooks.tsx | 5 ++- src/components/Ads/styled.tsx | 2 +- src/config/userAgent.tsx | 9 +++-- src/features/MatchesGrid/index.tsx | 5 +-- src/requests/getAds/getAds.tsx | 34 +++++++++---------- src/requests/getAds/updateAdsView.tsx | 8 ++--- 10 files changed, 42 insertions(+), 47 deletions(-) diff --git a/src/components/Ads/components/AdComponent/styled.tsx b/src/components/Ads/components/AdComponent/styled.tsx index 9e2e5530..01534e8f 100644 --- a/src/components/Ads/components/AdComponent/styled.tsx +++ b/src/components/Ads/components/AdComponent/styled.tsx @@ -1,4 +1,4 @@ -import styled from 'styled-components/macro' +import styled from 'styled-components' import { VIEW_ADS } from '../../types' type Props = { @@ -7,15 +7,15 @@ type Props = { const chooseStyle = (type: number) => { switch (true) { - case VIEW_ADS.COLUMN === type: + case VIEW_ADS[type] === 'COLUMN': return 'grid-row: 1 / 3; img {max-height: none;}' - case VIEW_ADS.ROW === type: + case VIEW_ADS[type] === 'ROW': return 'grid-column: 1 / 3' - case VIEW_ADS.SQUARE === type: + case VIEW_ADS[type] === 'SQUARE': return 'grid-row: 1 / 3; grid-column: 1 / 3; img {max-height: none;}' - case VIEW_ADS.SECOND_COLUMN === type: + case VIEW_ADS[type] === 'SECOND_COLUMN': return 'grid-column: 2 / 3; grid-row: 1 / 1' - case VIEW_ADS.SECOND_ROW === type: + case VIEW_ADS[type] === 'SECOND_ROW': return 'grid-column: 1 / 2; grid-row: 2 / 3;' default: return '' diff --git a/src/components/Ads/components/MobileAd/index.tsx b/src/components/Ads/components/MobileAd/index.tsx index 0ec082b8..bc117bbe 100644 --- a/src/components/Ads/components/MobileAd/index.tsx +++ b/src/components/Ads/components/MobileAd/index.tsx @@ -1,4 +1,4 @@ -import type { MouseEvent } from 'react' +import { MouseEvent } from 'react' import type { AdType } from 'requests' @@ -12,10 +12,10 @@ import { import { useAd } from '../AdComponent/hooks' import { EventGA } from '../../types' -type MobileAdTypes = { - ad: AdType, - className?: string, -} + type MobileAdTypes = { + ad: AdType, + className?: string, + } export const MobileAd = ({ ad, diff --git a/src/components/Ads/components/MobileAd/styled.tsx b/src/components/Ads/components/MobileAd/styled.tsx index 7330167c..98297112 100644 --- a/src/components/Ads/components/MobileAd/styled.tsx +++ b/src/components/Ads/components/MobileAd/styled.tsx @@ -1,4 +1,4 @@ -import styled from 'styled-components/macro' +import styled from 'styled-components' type Props = { position: number, diff --git a/src/components/Ads/helpers/calcMaxDurationAds.tsx b/src/components/Ads/helpers/calcMaxDurationAds.tsx index d052d7bb..7e1eac14 100644 --- a/src/components/Ads/helpers/calcMaxDurationAds.tsx +++ b/src/components/Ads/helpers/calcMaxDurationAds.tsx @@ -1,4 +1,4 @@ -import type { AdResponse, AdsListType } from 'requests' +import { AdResponse, AdsListType } from 'requests' export const calcMaxAdDurationAds = (advertisements: AdResponse) => { const allAds = Object.values(advertisements) diff --git a/src/components/Ads/hooks.tsx b/src/components/Ads/hooks.tsx index c2ac6fe6..f39ddc53 100644 --- a/src/components/Ads/hooks.tsx +++ b/src/components/Ads/hooks.tsx @@ -1,7 +1,4 @@ -import { useMemo } from 'react' - import { useQuery } from 'react-query' - import { useRecoilState } from 'recoil' import { isMobileDevice, querieKeys } from 'config' @@ -10,6 +7,8 @@ import { getAds } from 'requests' import { useLang } from 'features/LexicsStore/hooks/useLang' +import { useMemo } from 'react' + import { useAuthStore } from 'features/AuthStore' import { diff --git a/src/components/Ads/styled.tsx b/src/components/Ads/styled.tsx index 40296d8a..5f36a29c 100644 --- a/src/components/Ads/styled.tsx +++ b/src/components/Ads/styled.tsx @@ -1,4 +1,4 @@ -import styled, { css } from 'styled-components/macro' +import styled, { css } from 'styled-components' import { isMobileDevice } from 'config' diff --git a/src/config/userAgent.tsx b/src/config/userAgent.tsx index 4eed50ac..8b4eb3db 100644 --- a/src/config/userAgent.tsx +++ b/src/config/userAgent.tsx @@ -1,8 +1,7 @@ -export const device = navigator.userAgent - -export const isIOS = /iPad|iPhone|iPod/.test(device) +export const isIOS = /iPad|iPhone|iPod/.test(navigator.userAgent) -export const isAndroid = /Android/.test(device) +export const isAndroid = /Android/.test(navigator.userAgent) -export const isMobileDevice = /iPhone|Android/.test(device) +export const isMobileDevice = /iPhone|Android/.test(navigator.userAgent) +export const device = navigator.userAgent diff --git a/src/features/MatchesGrid/index.tsx b/src/features/MatchesGrid/index.tsx index 00bb7ea5..e6a48fa5 100644 --- a/src/features/MatchesGrid/index.tsx +++ b/src/features/MatchesGrid/index.tsx @@ -1,11 +1,7 @@ import { memo, useEffect } from 'react' - import { useRouteMatch } from 'react-router-dom' - import { useQuery } from 'react-query' -import { useRecoilValue } from 'recoil' - import { isMobileDevice, PAGES } from 'config' import type { AdType, LiveScore } from 'requests' @@ -18,6 +14,7 @@ import { useHeaderFiltersStore } from 'features/HeaderFilters' import { readToken } from 'helpers' +import { useRecoilValue } from 'recoil' import { Wrapper } from './styled' import { useMatchSwitchesStore } from '../MatchSwitches' import { querieKeys } from '../../config' diff --git a/src/requests/getAds/getAds.tsx b/src/requests/getAds/getAds.tsx index 42a71f3e..1f7c6982 100644 --- a/src/requests/getAds/getAds.tsx +++ b/src/requests/getAds/getAds.tsx @@ -10,27 +10,27 @@ export type AdsParams = { } export type AdType = { - duration: number, - frequency: number, - id: number, - impressions: number, - link: string, - media: { + '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, + '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, + 'time_close': number, + 'type': { + 'id': number, + 'name_eng': string, + 'name_rus': string, }, } diff --git a/src/requests/getAds/updateAdsView.tsx b/src/requests/getAds/updateAdsView.tsx index 88590e2d..27a9af5d 100644 --- a/src/requests/getAds/updateAdsView.tsx +++ b/src/requests/getAds/updateAdsView.tsx @@ -7,10 +7,10 @@ export type AdsViewParams = { } type AdsViewResponse = { - data: string, - message: string, - reason: string, - status: 'failed' | 'failed' | 'success', + 'data': string, + 'message': string, + 'reason': string, + 'status': 'failed' | 'failed' | 'success', } export const updateAdsView = (