feat(in-565): pr fixes

pull/265/head
Margarita 2 years ago committed by Gitea
parent 0170d0fb06
commit 63f7c01e09
  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,
])
const handleClose = async () => {
const handleClose = () => {
setIsOpenAd(false)
isMatchPage() && setIsNeedToShow(false)
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 { useLexicsStore } from 'features/LexicsStore'
import { useAd } from './hooks'
import { EventGA } from '../../types'
@ -33,9 +36,11 @@ export const AdComponent = memo(({ ad }: AdComponentType) => {
sendBannerClickEvent,
} = useAd({ ad })
const { suffix } = useLexicsStore()
const close = (e: MouseEvent<HTMLButtonElement>) => {
e.stopPropagation()
return handleClose()
handleClose()
}
const onLinkClick = () => {
@ -76,6 +81,7 @@ export const AdComponent = memo(({ ad }: AdComponentType) => {
<AdImg
src={media.url}
position={position.id}
alt={`name_${suffix}`}
/>
)}
</LinkWrapper>

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

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

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

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

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

@ -1,8 +1,4 @@
import {
useEffect,
useMemo,
useState,
} from 'react'
import { useEffect, useMemo } from 'react'
import { useHistory } from 'react-router'
import { useTour } from '@reactour/tour'
@ -28,7 +24,11 @@ import {
isMobileDevice,
} from 'config'
import { usePageLogger, usePageParams } from 'hooks'
import {
useScreenOrientation,
usePageLogger,
usePageParams,
} from 'hooks'
import { checkUrlParams } from 'helpers/parseUrlParams/parseUrlParams'
@ -46,6 +46,7 @@ import { Wrapper } from './styled'
const MatchPageComponent = () => {
usePageLogger()
const history = useHistory()
const orientation = useScreenOrientation()
const { addRemoveFavorite, userFavorites } = useUserFavoritesStore()
const { colors } = useTheme()
@ -111,20 +112,14 @@ const MatchPageComponent = () => {
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 handleOrientationChange = () => setOrientation(window.orientation)
window.addEventListener('orientationchange', handleOrientationChange)
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])
const currentAds = useMemo(
() => (find(ads, (ad) => ad.position.id === currentOrientation)),
[ads, currentOrientation],
)
return (
<PageWrapper

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

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

@ -85,7 +85,7 @@ export const MatchPlaylists = forwardRef(
return (
<List
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) => (

@ -8,7 +8,7 @@ import size from 'lodash/size'
import filter from 'lodash/filter'
import map from 'lodash/map'
import { isMobileDevice } from 'config/userAgent'
import { isMobileDevice } from 'config'
import type {
PlaylistOption,
@ -68,7 +68,7 @@ export const TabWatch = ({
{!isMobileDevice
&& 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} />)
)}
<DropdownSection

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

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

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

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

@ -9,3 +9,4 @@ export * from './useTooltip'
export * from './useModalRoot'
export * from './usePageLogger'
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