feat(in-565): pr fixes

pull/255/head
Margarita 2 years ago
parent edadb6f012
commit 18cc2b31eb
  1. 2
      src/components/Ads/components/AdComponent/hooks.tsx
  2. 10
      src/components/Ads/components/AdComponent/index.tsx
  3. 12
      src/components/Ads/components/MobileAd/index.tsx
  4. 15
      src/components/Ads/components/MobileAd/styled.tsx
  5. 2
      src/components/Ads/index.tsx
  6. 4
      src/components/Ads/types.tsx
  7. 4
      src/features/HomePage/index.tsx
  8. 33
      src/features/MatchPage/index.tsx
  9. 4
      src/features/MatchPage/store/hooks/index.tsx
  10. 9
      src/features/MatchSidePlaylists/components/EventsList/index.tsx
  11. 2
      src/features/MatchSidePlaylists/components/MatchPlaylists/index.tsx
  12. 4
      src/features/MatchSidePlaylists/components/TabWatch/index.tsx
  13. 14
      src/features/MatchSidePlaylists/index.tsx
  14. 4
      src/features/MatchesGrid/index.tsx
  15. 8
      src/features/StreamPlayer/index.tsx
  16. 8
      src/features/TournamentList/components/TournamentMobile/index.tsx
  17. 1
      src/hooks/index.tsx
  18. 14
      src/hooks/useScreenOrientation.tsx

@ -70,7 +70,7 @@ export const useAd = ({ ad }: AdComponentType) => {
currentAdsTime, currentAdsTime,
]) ])
const handleClose = async () => { const handleClose = () => {
setIsOpenAd(false) setIsOpenAd(false)
isMatchPage() && setIsNeedToShow(false) isMatchPage() && setIsNeedToShow(false)
sendBannerClickEvent(EventGA.CLOSE) sendBannerClickEvent(EventGA.CLOSE)

@ -1,7 +1,10 @@
import { memo, MouseEvent } from 'react' import type { MouseEvent } from 'react'
import { memo } from 'react'
import type { AdType } from 'requests' import type { AdType } from 'requests'
import { useLexicsStore } from 'features/LexicsStore'
import { useAd } from './hooks' import { useAd } from './hooks'
import { EventGA } from '../../types' import { EventGA } from '../../types'
@ -33,9 +36,11 @@ export const AdComponent = memo(({ ad }: AdComponentType) => {
sendBannerClickEvent, sendBannerClickEvent,
} = useAd({ ad }) } = useAd({ ad })
const { suffix } = useLexicsStore()
const close = (e: MouseEvent<HTMLButtonElement>) => { const close = (e: MouseEvent<HTMLButtonElement>) => {
e.stopPropagation() e.stopPropagation()
return handleClose() handleClose()
} }
const onLinkClick = () => { const onLinkClick = () => {
@ -76,6 +81,7 @@ export const AdComponent = memo(({ ad }: AdComponentType) => {
<AdImg <AdImg
src={media.url} src={media.url}
position={position.id} position={position.id}
alt={`name_${suffix}`}
/> />
)} )}
</LinkWrapper> </LinkWrapper>

@ -4,6 +4,8 @@ import includes from 'lodash/includes'
import type { AdType } from 'requests' import type { AdType } from 'requests'
import { useLexicsStore } from 'features/LexicsStore'
import { useAd } from '../AdComponent/hooks' import { useAd } from '../AdComponent/hooks'
import { EventGA, PLAYER_MOBILE_FULL_SCREEN } from '../../types' import { EventGA, PLAYER_MOBILE_FULL_SCREEN } from '../../types'
@ -25,6 +27,8 @@ export const MobileAd = ({ ad }: MobileAdTypes) => {
position, position,
} = ad } = ad
const { suffix } = useLexicsStore()
const { const {
handleClose, handleClose,
isNeedToShow, isNeedToShow,
@ -36,7 +40,7 @@ export const MobileAd = ({ ad }: MobileAdTypes) => {
const close = (e: MouseEvent<HTMLButtonElement>) => { const close = (e: MouseEvent<HTMLButtonElement>) => {
e.stopPropagation() e.stopPropagation()
return handleClose() handleClose()
} }
const onLinkClick = () => { const onLinkClick = () => {
@ -63,7 +67,11 @@ export const MobileAd = ({ ad }: MobileAdTypes) => {
{isVideo {isVideo
? <Video position={position.id} src={media.url} /> ? <Video position={position.id} src={media.url} />
: ( : (
<Img position={position.id} src={media.url} /> <Img
position={position.id}
src={media.url}
alt={`name_${suffix}`}
/>
)} )}
</MobileAdWrapper> </MobileAdWrapper>
) : null ) : null

@ -8,31 +8,30 @@ import {
MATCH_ADS, MATCH_ADS,
PLAYER_MOBILE_FULL_SCREEN, PLAYER_MOBILE_FULL_SCREEN,
PLAYER_MOBILE_ADS, PLAYER_MOBILE_ADS,
MATCH_PAGE_MOBILE_ADS,
} from '../../types' } from '../../types'
type Props = { type Props = {
position: number, position: number,
} }
const matchMobileAds = [16, 17, 22, 23, 24]
const chooseStyle = (type: number) => { const chooseStyle = (type: number) => {
switch (true) { switch (type) {
case MATCH_ADS.PLAYS_BOTTOM_MOBILE === type: case MATCH_ADS.PLAYS_BOTTOM_MOBILE:
return css` return css`
grid-row: 4; grid-row: 4;
margin-bottom: 12px; margin-bottom: 12px;
height: 48px; height: 48px;
` `
case PLAYER_MOBILE_ADS === type: case PLAYER_MOBILE_ADS:
return css` return css`
position: absolute; position: absolute;
width: 92%; width: 92%;
bottom: 50px; bottom: 50px;
left: 15px; left: 15px;
` `
case PLAYER_MOBILE_FULL_SCREEN.VERTICAL_FULL_SCREEN === type: case PLAYER_MOBILE_FULL_SCREEN.VERTICAL_FULL_SCREEN:
case PLAYER_MOBILE_FULL_SCREEN.HORIZONTAL_FULL_SCREEN === type: case PLAYER_MOBILE_FULL_SCREEN.HORIZONTAL_FULL_SCREEN:
return css` return css`
position: absolute; position: absolute;
top: 0; top: 0;
@ -84,7 +83,7 @@ export const Img = styled.img<Props>`
switch (true) { switch (true) {
case position === 10: case position === 10:
return '50px' return '50px'
case includes(matchMobileAds, position): case includes(MATCH_PAGE_MOBILE_ADS, position):
return '100%' return '100%'
default: default:
return '75px' return '75px'

@ -2,8 +2,8 @@ import type { AdType } from 'requests'
import { isMobileDevice } from 'config' import { isMobileDevice } from 'config'
import type { AdsPropsType } from './types'
import { AdComponent } from './components/AdComponent' import { AdComponent } from './components/AdComponent'
import { AdsPropsType } from './types'
import { MobileAd } from './components/MobileAd' import { MobileAd } from './components/MobileAd'
import { import {

@ -1,4 +1,4 @@
import { AdsListType } from 'requests' import type { AdsListType } from 'requests'
export enum PageType { export enum PageType {
HOME = 1, HOME = 1,
@ -52,6 +52,8 @@ export enum PLAYER_MOBILE_FULL_SCREEN {
HORIZONTAL_FULL_SCREEN = 24, HORIZONTAL_FULL_SCREEN = 24,
} }
export const MATCH_PAGE_MOBILE_ADS = [16, 17, 22, 23, 24]
export type AdsPropsType = Record<'ads', AdsListType | undefined> export type AdsPropsType = Record<'ads', AdsListType | undefined>
export const adsViews = 'adsViews' export const adsViews = 'adsViews'

@ -55,8 +55,8 @@ const Home = () => {
&& ( && (
<HeaderAds ads={ <HeaderAds ads={
isMobileDevice isMobileDevice
? ads?.mobile?.filter(({ position }) => HEADER_MOBILE_ADS.includes(position.id)) ? ads.mobile?.filter(({ position }) => HEADER_MOBILE_ADS.includes(position.id))
: ads?.header : ads.header
} }
/> />
)} )}

@ -1,8 +1,4 @@
import { import { useEffect, useMemo } from 'react'
useEffect,
useMemo,
useState,
} from 'react'
import { useHistory } from 'react-router' import { useHistory } from 'react-router'
import { useTour } from '@reactour/tour' import { useTour } from '@reactour/tour'
@ -28,7 +24,11 @@ import {
isMobileDevice, isMobileDevice,
} from 'config' } from 'config'
import { usePageLogger, usePageParams } from 'hooks' import {
useScreenOrientation,
usePageLogger,
usePageParams,
} from 'hooks'
import { checkUrlParams } from 'helpers/parseUrlParams/parseUrlParams' import { checkUrlParams } from 'helpers/parseUrlParams/parseUrlParams'
@ -46,6 +46,7 @@ import { Wrapper } from './styled'
const MatchPageComponent = () => { const MatchPageComponent = () => {
usePageLogger() usePageLogger()
const history = useHistory() const history = useHistory()
const orientation = useScreenOrientation()
const { addRemoveFavorite, userFavorites } = useUserFavoritesStore() const { addRemoveFavorite, userFavorites } = useUserFavoritesStore()
const { colors } = useTheme() const { colors } = useTheme()
@ -111,20 +112,14 @@ const MatchPageComponent = () => {
history.push(`/${sportName}/tournaments/${profile.tournament.id}`) history.push(`/${sportName}/tournaments/${profile.tournament.id}`)
} }
const [orientation, setOrientation] = useState(window.orientation) const currentOrientation = orientation === 0
? VERTICAL_FULL_SCREEN
: HORIZONTAL_FULL_SCREEN
useEffect(() => { const currentAds = useMemo(
const handleOrientationChange = () => setOrientation(window.orientation) () => (find(ads, (ad) => ad.position.id === currentOrientation)),
window.addEventListener('orientationchange', handleOrientationChange) [ads, currentOrientation],
return () => window.removeEventListener('orientationchange', handleOrientationChange) )
}, [])
const currentAds = useMemo(() => (
window.orientation === 0
? find(ads.mobile, (ad) => ad.position.id === VERTICAL_FULL_SCREEN)
: find(ads.mobile, (ad) => ad.position.id === HORIZONTAL_FULL_SCREEN)
// eslint-disable-next-line react-hooks/exhaustive-deps
), [ads.mobile, orientation])
return ( return (
<PageWrapper <PageWrapper

@ -9,7 +9,7 @@ import includes from 'lodash/includes'
import filter from 'lodash/filter' import filter from 'lodash/filter'
import isEmpty from 'lodash/isEmpty' import isEmpty from 'lodash/isEmpty'
import { PAGES } from 'config' import { isMobileDevice, PAGES } from 'config'
import { useAuthStore } from 'features/AuthStore' import { useAuthStore } from 'features/AuthStore'
import { Tabs } from 'features/MatchSidePlaylists/config' import { Tabs } from 'features/MatchSidePlaylists/config'
@ -410,7 +410,7 @@ export const useMatchPage = () => {
activeFirstTeamPlayers, activeFirstTeamPlayers,
activeSecondTeamPlayers, activeSecondTeamPlayers,
activeStatus, activeStatus,
ads, ads: isMobileDevice ? ads.mobile : ads.match,
allActionsToggle, allActionsToggle,
allPlayersToggle, allPlayersToggle,
applyFilters, applyFilters,

@ -64,6 +64,7 @@ export const EventsList = ({
const { suffix, translate } = useLexicsStore() const { suffix, translate } = useLexicsStore()
const { PLAYS_BOTTOM, PLAYS_BOTTOM_MOBILE } = MATCH_ADS const { PLAYS_BOTTOM, PLAYS_BOTTOM_MOBILE } = MATCH_ADS
const adsPositionId = isMobileDevice ? PLAYS_BOTTOM_MOBILE : PLAYS_BOTTOM
useEffect(() => { useEffect(() => {
if (selectedPlaylist?.tab === Tabs.EVENTS && isPlayingEpisode) { if (selectedPlaylist?.tab === Tabs.EVENTS && isPlayingEpisode) {
@ -99,12 +100,10 @@ export const EventsList = ({
<List> <List>
{ads {ads
&& isFirstBlock && isFirstBlock
&& map(ads, (ad: AdType) => ad?.position.id === adsPositionId
&& (isMobileDevice && (isMobileDevice
? map(ads?.mobile, (ad: AdType) => ad?.position.id === PLAYS_BOTTOM_MOBILE ? <MobileAd ad={ad} key={ad.id} />
&& <MobileAd ad={ad} key={ad.id} />) : <AdComponent ad={ad} key={ad.id} />))}
: map(ads?.match, (ad: AdType) => ad?.position.id === PLAYS_BOTTOM
&& <AdComponent ad={ad} key={ad.id} />)
)}
{map(events, (event) => { {map(events, (event) => {
if (!event.t && !event.pl) { if (!event.t && !event.pl) {
return ( return (

@ -85,7 +85,7 @@ export const MatchPlaylists = forwardRef(
return ( return (
<List <List
ref={ref} ref={ref}
isAdsExist={some(ads?.match, ({ position }) => position.id === MATCH_ADS.WATCH_TOP)} isAdsExist={some(ads, ({ position }) => position.id === MATCH_ADS.WATCH_TOP)}
> >
{ {
map(playlists, (playlist) => ( map(playlists, (playlist) => (

@ -8,7 +8,7 @@ import size from 'lodash/size'
import filter from 'lodash/filter' import filter from 'lodash/filter'
import map from 'lodash/map' import map from 'lodash/map'
import { isMobileDevice } from 'config/userAgent' import { isMobileDevice } from 'config'
import type { import type {
PlaylistOption, PlaylistOption,
@ -68,7 +68,7 @@ export const TabWatch = ({
{!isMobileDevice {!isMobileDevice
&& ads && ads
&& ( && (
map(ads?.match, (ad: AdType) => ad?.position.id === MATCH_ADS.WATCH_TOP map(ads, (ad: AdType) => ad?.position.id === MATCH_ADS.WATCH_TOP
&& <AdComponent ad={ad} key={ad.id} />) && <AdComponent ad={ad} key={ad.id} />)
)} )}
<DropdownSection <DropdownSection

@ -7,8 +7,6 @@ import { createPortal } from 'react-dom'
import { useTour } from '@reactour/tour' import { useTour } from '@reactour/tour'
import map from 'lodash/map'
import type { PlaylistOption } from 'features/MatchPage/types' import type { PlaylistOption } from 'features/MatchPage/types'
import { useMatchPageStore } from 'features/MatchPage/store' import { useMatchPageStore } from 'features/MatchPage/store'
import { import {
@ -21,15 +19,11 @@ import { Overlay } from 'components/Overlay'
import { useEventListener, useModalRoot } from 'hooks' import { useEventListener, useModalRoot } from 'hooks'
import { AdType } from 'requests'
import { isIOS, isMobileDevice } from 'config/userAgent' import { isIOS, isMobileDevice } from 'config/userAgent'
import { getLocalStorageItem } from 'helpers/getLocalStorage' import { getLocalStorageItem } from 'helpers/getLocalStorage'
import { MATCH_ADS } from 'components/Ads/types' import { MATCH_ADS } from 'components/Ads/types'
import { MobileAd } from 'components/Ads/components/MobileAd'
import { AdComponent } from 'components/Ads/components/AdComponent'
import { Tabs } from './config' import { Tabs } from './config'
import { TabEvents } from './components/TabEvents' import { TabEvents } from './components/TabEvents'
@ -49,6 +43,7 @@ import {
TabButton, TabButton,
EventsAdsWrapper, EventsAdsWrapper,
} from './styled' } from './styled'
import { HeaderAds } from '../../components/Ads'
const tabPanes = { const tabPanes = {
[Tabs.WATCH]: TabWatch, [Tabs.WATCH]: TabWatch,
@ -98,6 +93,7 @@ export const MatchSidePlaylists = ({
const [hasTabPaneScroll, setTabPaneScroll] = useState(false) const [hasTabPaneScroll, setTabPaneScroll] = useState(false)
const { PLAYS_TOP, PLAYS_TOP_MOBILE } = MATCH_ADS const { PLAYS_TOP, PLAYS_TOP_MOBILE } = MATCH_ADS
const adsPositionId = isMobileDevice ? PLAYS_TOP_MOBILE : PLAYS_TOP
useEffect(() => { useEffect(() => {
const { const {
@ -156,11 +152,7 @@ export const MatchSidePlaylists = ({
&& ads && ads
&& ( && (
<EventsAdsWrapper hasScroll={hasTabPaneScroll}> <EventsAdsWrapper hasScroll={hasTabPaneScroll}>
{isMobileDevice <HeaderAds ads={ads.filter(({ position }) => position.id === adsPositionId)} />
? map(ads?.mobile, (ad: AdType) => ad?.position.id === PLAYS_TOP_MOBILE
&& <MobileAd ad={ad} key={ad.id} />)
: map(ads?.match, (ad: AdType) => ad?.position.id === PLAYS_TOP
&& <AdComponent ad={ad} key={ad.id} />)}
</EventsAdsWrapper> </EventsAdsWrapper>
)} )}
<TabsGroup> <TabsGroup>

@ -33,7 +33,7 @@ export const MatchesGrid = memo(({ matches }: MatchesGridProps) => {
const { ads } = useHomePage() const { ads } = useHomePage()
const currentAds = ads?.match_cell?.length ? ads?.match_cell : ads?.block const currentAds = ads.match_cell?.length ? ads.match_cell : ads.block
const { const {
compareSport, compareSport,
@ -91,7 +91,7 @@ export const MatchesGrid = memo(({ matches }: MatchesGridProps) => {
&& readToken() && readToken()
&& currentAds && currentAds
&& ( && (
currentAds?.map((ad: AdType) => <AdComponent ad={ad} />) currentAds.map((ad: AdType) => <AdComponent ad={ad} />)
)} )}
{isHomePage && isShowTournament ? ( {isHomePage && isShowTournament ? (
<TournamentList matches={filteredMatches()} /> <TournamentList matches={filteredMatches()} />

@ -129,11 +129,9 @@ export const StreamPlayer = (props: Props) => {
{ads {ads
&& ( && (
<PlayerAdsWrapper isFullscreen={isFullscreen}> <PlayerAdsWrapper isFullscreen={isFullscreen}>
<HeaderAds ads={ <HeaderAds ads={ads.filter(({ position }) => (isMobileDevice
isMobileDevice ? position.id === PLAYER_MOBILE_ADS
? ads?.mobile?.filter(({ position }) => position.id === PLAYER_MOBILE_ADS) : includes(PLAYER_ADS, position.id)))}
: ads?.match?.filter(({ position }) => includes(PLAYER_ADS, position.id))
}
/> />
</PlayerAdsWrapper> </PlayerAdsWrapper>
)} )}

@ -90,8 +90,8 @@ export const TournamentMobile = ({
</CardWrapper> </CardWrapper>
<ScMatchesWrapper> <ScMatchesWrapper>
{open && ( {open && (
<> <Fragment>
{isMobileDevice && ads?.mobile?.map((ad: AdType) => ( {isMobileDevice && ads.mobile?.map((ad: AdType) => (
ad.position.id === VIEW_ADS.MOBILE_IN_COLLAPSE_HEADER && ( ad.position.id === VIEW_ADS.MOBILE_IN_COLLAPSE_HEADER && (
<TournamentMobileAd <TournamentMobileAd
ad={ad} ad={ad}
@ -101,14 +101,14 @@ export const TournamentMobile = ({
{tournamentMatches?.map((match: Match) => ( {tournamentMatches?.map((match: Match) => (
<MatchCard key={match.id} match={match} /> <MatchCard key={match.id} match={match} />
))} ))}
{isMobileDevice && ads?.mobile?.map((ad: AdType) => ( {isMobileDevice && ads.mobile?.map((ad: AdType) => (
ad.position.id === VIEW_ADS.MOBILE_IN_COLLAPSE_FOOTER && ( ad.position.id === VIEW_ADS.MOBILE_IN_COLLAPSE_FOOTER && (
<TournamentMobileAd <TournamentMobileAd
ad={ad} ad={ad}
key={ad.id} key={ad.id}
/> />
)))} )))}
</> </Fragment>
)} )}
</ScMatchesWrapper> </ScMatchesWrapper>
</CardWrapperOuter> </CardWrapperOuter>

@ -9,3 +9,4 @@ export * from './useTooltip'
export * from './useModalRoot' export * from './useModalRoot'
export * from './usePageLogger' export * from './usePageLogger'
export * from './useDuration' export * from './useDuration'
export * from './useScreenOrientation'

@ -0,0 +1,14 @@
import { useState } from 'react'
import { useEventListener } from './useEventListener'
export const useScreenOrientation = () => {
const [orientation, setOrientation] = useState(window.orientation)
useEventListener({
callback: (e) => setOrientation(window.orientation),
event: 'orientationchange',
})
return orientation
}
Loading…
Cancel
Save