diff --git a/src/components/Ads/components/AdComponent/hooks.tsx b/src/components/Ads/components/AdComponent/hooks.tsx index de130741..ff2f3f32 100644 --- a/src/components/Ads/components/AdComponent/hooks.tsx +++ b/src/components/Ads/components/AdComponent/hooks.tsx @@ -27,8 +27,10 @@ import { const countryCode = getLocalStorageItem(COUNTRY) export const useAd = ({ ad }: AdComponentType) => { - const [isOpenAd, setIsOpenAd] = useState(true) - const [isNeedToShow, setIsNeedToShow] = useState(true) + const isMatch = isMatchPage() + + const [isOpenAd, setIsOpenAd] = useState(isMatch) + const [isNeedToShow, setIsNeedToShow] = useState(isMatch) const [shownTime, setShownTime] = useState(0) const { isFullscreen } = useMatchPageStore() @@ -72,7 +74,7 @@ export const useAd = ({ ad }: AdComponentType) => { const handleClose = () => { setIsOpenAd(false) - isMatchPage() && setIsNeedToShow(false) + isMatch && setIsNeedToShow(false) sendBannerClickEvent(EventGA.CLOSE) } @@ -89,7 +91,7 @@ export const useAd = ({ ad }: AdComponentType) => { useEffect(() => { setShownTime(0) - if (isMatchPage()) { + if (isMatch) { const interval = setInterval(() => { setIsNeedToShow(true) setIsOpenAd(true) @@ -105,6 +107,7 @@ export const useAd = ({ ad }: AdComponentType) => { isNeedToShow, views?.HOME, isNeedBanner, + isMatch, ]) useEffect(() => { @@ -136,14 +139,18 @@ export const useAd = ({ ad }: AdComponentType) => { ]) useEffect(() => { - if (!isNeedToShow || (!isMatchPage() && !isNeedBanner)) return + if (!isNeedToShow || (!isMatch && !isNeedBanner)) return (async () => { await updateAdsView({ adv_id: id }) })() sendBannerClickEvent(EventGA.DISPLAY) // eslint-disable-next-line react-hooks/exhaustive-deps - }, [id, isNeedToShow]) + }, [ + id, + isNeedToShow, + isMatch, + ]) return { handleClose, diff --git a/src/components/Ads/components/MobileAd/styled.tsx b/src/components/Ads/components/MobileAd/styled.tsx index 8be5ded7..7eb6b0fe 100644 --- a/src/components/Ads/components/MobileAd/styled.tsx +++ b/src/components/Ads/components/MobileAd/styled.tsx @@ -9,6 +9,7 @@ import { PLAYER_MOBILE_FULL_SCREEN, PLAYER_MOBILE_ADS, MATCH_PAGE_MOBILE_ADS, + VIEW_ADS, } from '../../types' type Props = { @@ -40,6 +41,9 @@ const chooseStyle = (type: number) => { padding: 5px; background-color: rgba(0, 0, 0, 0.7); ` + case VIEW_ADS.MOBILE_IN_COLLAPSE_FOOTER: + case VIEW_ADS.MOBILE_IN_COLLAPSE_HEADER: + return 'margin-top: 6px' default: return '' } @@ -48,7 +52,7 @@ const chooseStyle = (type: number) => { export const MobileAdWrapper = styled.div` position: relative; width: 100%; - z-index: ${({ position }) => (includes(PLAYER_MOBILE_FULL_SCREEN, position) ? '101' : '100')}; + z-index: ${({ position }) => (includes(PLAYER_MOBILE_FULL_SCREEN, position) ? '101' : '4')}; ${({ position }) => chooseStyle(position)}; ` diff --git a/src/features/AuthStore/helpers.tsx b/src/features/AuthStore/helpers.tsx index d8d08216..0f5784c6 100644 --- a/src/features/AuthStore/helpers.tsx +++ b/src/features/AuthStore/helpers.tsx @@ -54,11 +54,11 @@ const redirectUrl = () => { // @ts-ignore || Boolean(clientsForRedirect[client.name]) ): - return `${window.origin}/redirect` + return `${window.origin}` case (ENV === 'staging' || ENV === 'preproduction'): - return `https://${stageENV}.insports.tv/redirect` + return `https://${stageENV}.insports.tv` default: - return `https://${clientName}.tv/redirect` + return `https://${clientName}.tv` } } diff --git a/src/features/AuthStore/hooks/useAuth.tsx b/src/features/AuthStore/hooks/useAuth.tsx index 558d4df0..da11b4f1 100644 --- a/src/features/AuthStore/hooks/useAuth.tsx +++ b/src/features/AuthStore/hooks/useAuth.tsx @@ -158,6 +158,8 @@ export const useAuth = () => { } const signinRedirectCallback = useCallback(() => { + setPage(history.location.pathname) + userManager.signinRedirectCallback() .then((loadedUser) => { storeUser(loadedUser) @@ -171,7 +173,6 @@ export const useAuth = () => { markUserLoaded() setPage('') setSearch('') - // } }).catch(login) // eslint-disable-next-line react-hooks/exhaustive-deps }, [ @@ -181,7 +182,13 @@ export const useAuth = () => { ]) useEffect(() => { - const isRedirectedBackFromAuthProvider = history.location.pathname === '/redirect' + const urlSearch = new URLSearchParams(history.location.search) + const searchToken = urlSearch.get('access_token') + const searchRefToken = urlSearch.get('id_token') + const searchExp = urlSearch.get('expires_in') + + const isRedirectedBackFromAuthProvider = Boolean(searchToken && searchRefToken && searchExp) + isRedirectedBackFromAuthProvider ? signinRedirectCallback() : checkUser() // eslint-disable-next-line react-hooks/exhaustive-deps }, [ diff --git a/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx b/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx index 7bda0907..ac6bc17f 100644 --- a/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx +++ b/src/features/HeaderFilters/components/DateFilter/hooks/index.tsx @@ -74,6 +74,13 @@ export const useDateFilter = () => { validator, }) + const addAdsViews = () => { + setAdsViews({ + ...adsViews, + HOME: (adsViews.HOME ?? 0) + 1, + }) + } + useEffect(() => { if (lastDate === selectedDate.getDate() && parseFilters @@ -85,20 +92,18 @@ 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]) const onPreviousClick = () => { + addAdsViews() const numberAddDays = weekName === 'Mon' ? -1 : -7 setSelectedDate(addDays(selectedDate, numberAddDays)) } const onNextClick = () => { + addAdsViews() const numberAddDays = weekName === 'Sun' ? 1 : 7 setSelectedDate(addDays(selectedDate, numberAddDays)) } @@ -108,6 +113,7 @@ export const useDateFilter = () => { const onDateChange = (newDate: Date | null) => { if (newDate) { + addAdsViews() setSelectedDate(newDate) close() } @@ -119,6 +125,7 @@ export const useDateFilter = () => { } return { + addAdsViews, close, date, isMonthMode, diff --git a/src/features/HeaderFilters/components/DateFilter/index.tsx b/src/features/HeaderFilters/components/DateFilter/index.tsx index 88a97353..4f65973b 100644 --- a/src/features/HeaderFilters/components/DateFilter/index.tsx +++ b/src/features/HeaderFilters/components/DateFilter/index.tsx @@ -26,6 +26,7 @@ import { useHeaderFiltersStore } from '../../store' export const DateFilter = () => { const { + addAdsViews, close, date, isOpen, @@ -72,6 +73,7 @@ export const DateFilter = () => { selected={day.date.getDate() === selectedDate.getDate()} onClick={() => { if (day.date.getDate() !== selectedDate.getDate()) { + addAdsViews() onWeekDayClick(day.date) } else { resetFilters() diff --git a/src/features/HeaderFilters/components/FacrDateFilter/index.tsx b/src/features/HeaderFilters/components/FacrDateFilter/index.tsx index 19f186da..a6ccd5e7 100644 --- a/src/features/HeaderFilters/components/FacrDateFilter/index.tsx +++ b/src/features/HeaderFilters/components/FacrDateFilter/index.tsx @@ -38,6 +38,7 @@ import { export const FacrDateFilter = () => { const { + addAdsViews, close, date, isMonthMode, @@ -151,6 +152,7 @@ export const FacrDateFilter = () => { selected={day.date.getDate() === selectedDate.getDate()} onClick={() => { if (day.date.getDate() !== selectedDate.getDate()) { + addAdsViews() onWeekDayClick(day.date) } else { resetFilters() diff --git a/src/features/MatchPage/store/hooks/usePlayersStats.tsx b/src/features/MatchPage/store/hooks/usePlayersStats.tsx index d608a597..e5fb4e7f 100644 --- a/src/features/MatchPage/store/hooks/usePlayersStats.tsx +++ b/src/features/MatchPage/store/hooks/usePlayersStats.tsx @@ -147,9 +147,6 @@ export const usePlayersStats = ({ || !includes([StatsTabs.TEAM1, StatsTabs.TEAM2], selectedStatsTable) || !matchProfile?.team1.id || !matchProfile?.team2.id - || (!matchProfile?.live && !isCurrentStats && !isEmpty(playersStats[isTeam1Selected - ? matchProfile.team1.id - : matchProfile.team2.id])) ) return const [res1, res2] = await Promise.all([ @@ -201,7 +198,6 @@ export const usePlayersStats = ({ fakeData, selectedTab, selectedStatsTable, - isCurrentStats, ]) const beforeCloseTourCallback = () => { diff --git a/src/features/MatchPage/store/hooks/useStatsTab.tsx b/src/features/MatchPage/store/hooks/useStatsTab.tsx index 2f1666f1..8baf5d26 100644 --- a/src/features/MatchPage/store/hooks/useStatsTab.tsx +++ b/src/features/MatchPage/store/hooks/useStatsTab.tsx @@ -63,8 +63,9 @@ export const useStatsTab = ({ const newStatsType = isFinalStatsType ? StatsType.CURRENT_STATS : StatsType.FINAL_STATS setStatsType(newStatsType) - setIsTeamsStatsFetching(true) - setIsPlayersStatsFetching(true) + selectedStatsTable === StatsTabs.TEAMS + ? setIsTeamsStatsFetching(true) + : setIsPlayersStatsFetching(true) } const getEpisodesToPlay = (episodes: Episodes) => map(episodes, (episode, i) => ({ diff --git a/src/features/MatchPage/store/hooks/useTeamsStats.tsx b/src/features/MatchPage/store/hooks/useTeamsStats.tsx index 2e92672d..623f6575 100644 --- a/src/features/MatchPage/store/hooks/useTeamsStats.tsx +++ b/src/features/MatchPage/store/hooks/useTeamsStats.tsx @@ -100,7 +100,6 @@ export const useTeamsStats = ({ || !videoBounds || selectedTab !== Tabs.STATS || selectedStatsTable !== StatsTab.TEAMS - || (!matchProfile?.live && !isCurrentStats && !isEmpty(teamsStats)) ) return try { @@ -131,7 +130,6 @@ export const useTeamsStats = ({ getFirstClickableParam, selectedTab, selectedStatsTable, - isCurrentStats, ]) const beforeCloseTourCallback = () => { diff --git a/src/features/UserAccount/components/PagePersonalInfo/hooks/index.tsx b/src/features/UserAccount/components/PagePersonalInfo/hooks/index.tsx index b2cb69e7..d381f516 100644 --- a/src/features/UserAccount/components/PagePersonalInfo/hooks/index.tsx +++ b/src/features/UserAccount/components/PagePersonalInfo/hooks/index.tsx @@ -78,13 +78,15 @@ export const useUserInfo = () => { setLoader(true) saveUserInfo(data).then(() => { fetchUserInfo() - + }).finally(() => { const lang_iso = find(languageList, (language) => language.id === data.language_id)?.iso_639_1 if (lang_iso) { changeLang(lang_iso) } - }).finally(() => setLoader(false)) + + setLoader(false) + }) // eslint-disable-next-line react-hooks/exhaustive-deps }, [fetchUserInfo])