From 3aca022f7bebe89aa032837fb85f79c90d04a5c6 Mon Sep 17 00:00:00 2001 From: Andrei Dekterev Date: Mon, 23 Jan 2023 15:22:36 +0700 Subject: [PATCH] fix(#175): fix add to favourites and acces to match --- .../AuthServiceApp/components/Oauth/hooks.tsx | 3 +-- .../components/SubscriptionGuard/index.tsx | 2 +- src/features/MatchPage/index.tsx | 2 +- src/features/MatchPage/store/hooks/index.tsx | 2 +- src/features/StreamPlayer/index.tsx | 17 ++++++++++------- src/features/SystemSettings/hooks.tsx | 4 ++++ 6 files changed, 18 insertions(+), 12 deletions(-) diff --git a/src/features/AuthServiceApp/components/Oauth/hooks.tsx b/src/features/AuthServiceApp/components/Oauth/hooks.tsx index 02cab2d6..0d1f0801 100644 --- a/src/features/AuthServiceApp/components/Oauth/hooks.tsx +++ b/src/features/AuthServiceApp/components/Oauth/hooks.tsx @@ -9,11 +9,10 @@ import { } from 'react' import { isValidEmail } from 'features/AuthServiceApp/helpers/isValidEmail' +import { API_ROOT } from 'features/AuthServiceApp/config/routes' import { addAccessTokenToUrl } from 'helpers/languageUrlParam' -import { API_ROOT } from 'config/routes' - export const useOauth = () => { const [email, setEmail] = useState('') const [error, setError] = useState('') diff --git a/src/features/MatchPage/components/SubscriptionGuard/index.tsx b/src/features/MatchPage/components/SubscriptionGuard/index.tsx index 1d2bcac5..81774c69 100644 --- a/src/features/MatchPage/components/SubscriptionGuard/index.tsx +++ b/src/features/MatchPage/components/SubscriptionGuard/index.tsx @@ -42,7 +42,7 @@ export const SubscriptionGuard = ({ children }: Props) => { return ( - {matchProfile?.sub ? children : null} + {matchProfile?.sub || !user ? children : null} ) } diff --git a/src/features/MatchPage/index.tsx b/src/features/MatchPage/index.tsx index 6851a6e5..5e35b73f 100644 --- a/src/features/MatchPage/index.tsx +++ b/src/features/MatchPage/index.tsx @@ -36,7 +36,7 @@ const MatchPageComponent = () => { profile, user, } = useMatchPageStore() - const isFavorite = profile && userFavorites.find((fav) => fav.id === profile?.tournament.id) + const isFavorite = profile && userFavorites?.find((fav) => fav.id === profile?.tournament.id) const { profileType, diff --git a/src/features/MatchPage/store/hooks/index.tsx b/src/features/MatchPage/store/hooks/index.tsx index 586a47c3..01e483bd 100644 --- a/src/features/MatchPage/store/hooks/index.tsx +++ b/src/features/MatchPage/store/hooks/index.tsx @@ -90,7 +90,7 @@ export const useMatchPage = () => { if (error || (duration && Number(duration) > ACCESS_TIME)) { setAccess(false) } - }), 1000 * 5, + }), 1000 * 30, ) // eslint-disable-next-line return () => clearInterval(getIntervalMatch) diff --git a/src/features/StreamPlayer/index.tsx b/src/features/StreamPlayer/index.tsx index a91a03c5..19378c6c 100644 --- a/src/features/StreamPlayer/index.tsx +++ b/src/features/StreamPlayer/index.tsx @@ -90,6 +90,7 @@ export const StreamPlayer = (props: Props) => { volumeInPercent, wrapperRef, } = useVideoPlayer(props) + return ( { selectedAudioTrack={selectedAudioTrack} /> - !user && + {!user && ( + + )} ) } diff --git a/src/features/SystemSettings/hooks.tsx b/src/features/SystemSettings/hooks.tsx index b5204ec6..8ab7df2e 100644 --- a/src/features/SystemSettings/hooks.tsx +++ b/src/features/SystemSettings/hooks.tsx @@ -9,6 +9,8 @@ import { SELECTED_API_KEY } from 'helpers/selectedApi' import { useToggle } from 'hooks/useToggle' import { useLocalStore } from 'hooks/useStorage' +import { removeToken } from '../../helpers' +import { removeCookie } from '../../helpers/cookie' type FormElement = HTMLFormElement & { api: HTMLInputElement & { @@ -34,6 +36,8 @@ export const useSystemSettings = () => { const { api } = e.currentTarget setSelectedApi(api.value) + removeToken() + removeCookie('access_token') window.location.reload() }