fix(remove guard for paid matches): remove guard for paid matches

pull/39/head
Andrei Dekterev 3 years ago
parent 90af38ce77
commit 8fe116103d
  1. 2
      src/components/AccessTimer/styled.tsx
  2. 2
      src/components/SimplePopup/index.tsx
  3. 10
      src/components/SimplePopup/styled.tsx
  4. 3
      src/features/App/index.tsx
  5. 3
      src/features/AuthServiceApp/components/Login/hooks.tsx
  6. 2
      src/features/AuthServiceApp/components/Oauth/hooks.tsx
  7. 3
      src/features/AuthServiceApp/components/RegisterPopup/styled.tsx
  8. 3
      src/features/AuthServiceApp/requests/register.tsx
  9. 3
      src/features/MatchCard/hooks.tsx
  10. 5
      src/features/MatchPage/components/SubscriptionGuard/index.tsx
  11. 2
      src/features/MatchPage/store/hooks/index.tsx
  12. 18
      src/features/Matches/helpers/getMatchClickAction/index.tsx
  13. 10
      src/features/Matches/helpers/prepareMatches.tsx
  14. 10
      src/features/Matches/hooks.tsx
  15. 4
      src/features/Menu/index.tsx
  16. 5
      src/features/MultiSourcePlayer/index.tsx
  17. 2
      src/features/StreamPlayer/index.tsx
  18. 3
      src/features/TournamentPage/hooks.tsx
  19. 7
      src/requests/getTokenVirtualUser.tsx

@ -1,6 +1,6 @@
import styled, { css } from 'styled-components/macro'
import { isMobileDevice } from 'config/userAgent'
import { isMobileDevice } from 'config'
import { ButtonSolid } from 'features/Common'

@ -1,4 +1,4 @@
import { ReactNode } from 'react'
import type { ReactNode } from 'react'
import { T9n } from 'features/T9n'

@ -1,6 +1,6 @@
import styled, { css } from 'styled-components/macro'
import { isMobileDevice } from 'config/userAgent'
import { isMobileDevice } from 'config'
import { ModalWindow } from 'features/Modal/styled'
import {
@ -9,9 +9,8 @@ import {
Modal as BaseModal,
HeaderTitle,
} from 'features/AuthServiceApp/components/RegisterPopup/styled'
import { Header as BaseHeader } from 'features/PopupComponents'
import { client } from 'features/AuthServiceApp/config/clients/index'
import { Header as BaseHeader } from '../../features/PopupComponents'
export const Modal = styled(BaseModal)`
@ -58,7 +57,7 @@ export const ScHeaderTitle = styled(HeaderTitle)`
${isMobileDevice
? css`
font-size: 20px;
line-height: 24px;
line-height: 24px;
@media screen and (orientation: landscape) {
font-size: 17px;
@ -142,9 +141,6 @@ export const Footer = styled.div`
${isMobileDevice
? css`
padding-top: 30px;
@media screen and (orientation: landscape) {
}
`
: ''};
`

@ -12,6 +12,8 @@ import { client } from 'config/clients'
import { matomoInstance } from 'config/matomo'
import { isAvailable } from 'config/env'
import { readToken } from 'helpers'
import { setClientTitleAndDescription } from 'helpers/setClientHeads'
import { GlobalStores } from 'features/GlobalStores'
@ -22,7 +24,6 @@ import { Theme } from 'features/Theme'
import { UnavailableText } from 'components/UnavailableText'
import { AuthenticatedApp } from './AuthenticatedApp'
import { readToken } from '../../helpers'
import { useAuthStore } from '../AuthStore'
setClientTitleAndDescription(client.title, client.description)

@ -16,10 +16,11 @@ import { loginCheck } from 'features/AuthServiceApp/requests/auth'
import { getApiUrl } from 'features/AuthServiceApp/config/routes'
import { useAuthFields } from 'features/AuthServiceApp/hooks/useAuthFields'
import { addAccessTokenToUrl } from 'helpers/languageUrlParam'
import { AuthProviders } from '../../config/authProviders'
import { getAuthUrl } from '../../helpers/getAuthUrl'
import { useParamsUrl } from '../../hooks/useParamsUrl'
import { addAccessTokenToUrl } from '../../../../helpers/languageUrlParam'
const url = getApiUrl('/authorize')

@ -12,7 +12,7 @@ import { isValidEmail } from 'features/AuthServiceApp/helpers/isValidEmail'
import { addAccessTokenToUrl } from 'helpers/languageUrlParam'
import { API_ROOT } from '../../config/routes'
import { API_ROOT } from 'config/routes'
export const useOauth = () => {
const [email, setEmail] = useState('')

@ -6,11 +6,10 @@ import { devices } from 'config/devices'
import { ModalWindow } from 'features/Modal/styled'
import { Modal as BaseModal } from 'features/Modal'
import { Header as BaseHeader } from 'features/PopupComponents'
import { client } from 'features/AuthServiceApp/config/clients'
import { ButtonSolid } from 'features/Common'
import { client } from '../../config/clients'
export const Modal = styled(BaseModal)`
background-color: rgba(0, 0, 0, 0.7);
padding: 0 60px;

@ -1,7 +1,8 @@
import type { ClientIds } from 'config/clients/types'
import { checkCookie } from 'helpers/cookie'
import { getApiUrl } from 'features/AuthServiceApp/config/routes'
import { checkCookie } from '../../../helpers/cookie'
const errorLexics = {
1: 'error_invalid_email_or_password',

@ -34,6 +34,9 @@ export const useCard = (match: Match) => {
const onMatchClick = useCallback(() => {
switch (match.access) {
case MatchAccess.ViewMatchPopupWithoutUser:
redirectToMatchPage()
break
case MatchAccess.CanBuyMatch:
openBuyMatchPopup(match)
break

@ -6,9 +6,9 @@ import { usePageParams } from 'hooks/usePageParams'
import { useBuyMatchPopupStore } from 'features/BuyMatchPopup'
import { useMatchPageStore } from 'features/MatchPage/store'
import { checkUrlParams, getAllUrlParams } from 'helpers/parseUrlParams/parseUrlParams'
import { prepareMatchProfile } from '../../helpers/prepareMatchProfile'
import { useAuthStore } from '../../../AuthStore'
import { checkUrlParams, getAllUrlParams } from '../../../../helpers/parseUrlParams/parseUrlParams'
type Props = {
children: ReactNode,
@ -21,8 +21,7 @@ export const SubscriptionGuard = ({ children }: Props) => {
const { user } = useAuthStore()
useEffect(() => {
if (matchProfile && !matchProfile.sub && !user) {
if (matchProfile && (
if (user && matchProfile && (
!matchProfile.sub
|| (checkUrlParams('subscribe')
&& getAllUrlParams('id')))) {

@ -9,6 +9,7 @@ import filter from 'lodash/filter'
import isEmpty from 'lodash/isEmpty'
import { FULL_GAME_KEY } from 'features/MatchPage/helpers/buildPlaylists'
import { useAuthStore } from 'features/AuthStore'
import type { MatchInfo } from 'requests/getMatchInfo'
import { getMatchInfo } from 'requests/getMatchInfo'
@ -23,7 +24,6 @@ import { useTournamentData } from './useTournamentData'
import { useMatchData } from './useMatchData'
import { useFiltersPopup } from './useFitersPopup'
import { useTabEvents } from './useTabEvents'
import { useAuthStore } from '../../../AuthStore'
const ACCESS_TIME = 60

@ -1,23 +1,29 @@
import type { Match } from 'requests'
import type { User } from 'oidc-client'
export enum MatchAccess {
CanBuyMatch = 'CanBuyMatch',
NoAccess = 'NoAccess',
NoCountryAccess = 'NoCountryAccess',
RedirectToProfile = 'RedirectToProfile',
ViewMatchPopup = 'ViewMatchPopup',
ViewMatchPopupWithoutUser = 'ViewMatchPopupWithoutUser',
}
export const getMatchAccess = ({
access,
date,
live,
sub,
}: Match) => {
export const getMatchAccess = (match: Match, user: User | undefined) => {
const {
access,
date,
live,
sub,
} = match
const dateToMs = Date.parse(date?.replace(/ /, 'T')) // без замены не будет работать в сафари
const dateNowMin10 = dateToMs - 10 * 60 * 1000
switch (true) {
case !user:
return MatchAccess.ViewMatchPopupWithoutUser
case !sub:
return MatchAccess.CanBuyMatch
case !access:

@ -2,13 +2,15 @@ import map from 'lodash/map'
import orderBy from 'lodash/orderBy'
import format from 'date-fns/format'
import type { User } from 'oidc-client'
import type { Match } from 'requests'
import { parseDate } from 'helpers/parseDate'
import { getMatchAccess } from './getMatchClickAction'
const prepareMatch = (match: Match) => {
const prepareMatch = (match: Match, user?: User | undefined) => {
const {
calc,
country,
@ -31,7 +33,7 @@ const prepareMatch = (match: Match) => {
const date = parseDate(matchDate)
return {
access: getMatchAccess(match),
access: getMatchAccess(match, user),
calc,
countryId: country_id,
countryInfo: country,
@ -54,10 +56,10 @@ const prepareMatch = (match: Match) => {
}
}
export const prepareMatches = (matches: Array<Match>) => {
export const prepareMatches = (matches: Array<Match>, user?: User | undefined) => {
const preparedMatches = map(
matches,
prepareMatch,
(match) => prepareMatch(match, user),
)
return orderBy(
preparedMatches,

@ -15,6 +15,8 @@ import { isMobileDevice } from 'config/userAgent'
import { prepareMatches } from './helpers/prepareMatches'
import { useAuthStore } from '../AuthStore'
export type Match = ReturnType<typeof prepareMatches>[number]
export type Props = {
@ -33,6 +35,7 @@ const initialState = {
export const useMatches = ({ fetch }: Props) => {
const { userPreferences } = usePreferencesStore()
const { user } = useAuthStore()
const {
isFetching,
request: requestMatches,
@ -81,10 +84,11 @@ export const useMatches = ({ fetch }: Props) => {
}, [fetchMatches, userPreferences])
const preparedMatches = useMemo(() => ({
broadcast: prepareMatches(matches.broadcast),
features: prepareMatches(matches.features),
highlights: prepareMatches(matches.highlights),
broadcast: prepareMatches(matches.broadcast, user),
features: prepareMatches(matches.features, user),
highlights: prepareMatches(matches.highlights, user),
isVideoSections: matches.isVideoSections,
// eslint-disable-next-line react-hooks/exhaustive-deps
}), [matches])
return {

@ -6,6 +6,8 @@ import { PAGES } from 'config/pages'
import { usePreferencesStore } from 'features/PreferencesPopup'
import { useTournamentPopupStore } from 'features/TournamentsPopup/store'
import { useAuthStore } from 'features/AuthStore'
import { FavoritesMobilePopup } from '../FavoritesMobilePopup'
import {
@ -14,8 +16,6 @@ import {
Icon,
} from './styled'
import { useAuthStore } from '../AuthStore'
export const Menu = () => {
const { openPopup } = usePreferencesStore()
const { open } = useTournamentPopupStore()

@ -14,15 +14,16 @@ import { Controls } from 'features/StreamPlayer/components/Controls'
import { Name } from 'features/Name'
import RewindMobile from 'features/StreamPlayer/components/RewindMobile'
import { FiltersPopup } from 'features/MatchSidePlaylists/components/FiltersPopup'
import { useAuthStore } from 'features/AuthStore'
import { isMobileDevice } from 'config/userAgent'
import { AccessTimer } from 'components/AccessTimer'
import type { Props } from './hooks'
import { useMultiSourcePlayer } from './hooks'
import { Players } from './types'
import { REWIND_SECONDS } from './config'
import { AccessTimer } from '../../components/AccessTimer'
import { useAuthStore } from '../AuthStore'
export const MultiSourcePlayer = (props: Props) => {
const {

@ -5,6 +5,7 @@ import { Name } from 'features/Name'
import { FiltersPopup } from 'features/MatchSidePlaylists/components/FiltersPopup'
import { WaterMark } from 'components/WaterMark'
import { AccessTimer } from 'components/AccessTimer'
import { isMobileDevice } from 'config/userAgent'
@ -25,7 +26,6 @@ import { useVideoPlayer } from './hooks'
import { useAuthStore } from '../AuthStore'
import { Controls } from './components/Controls'
import RewindMobile from './components/RewindMobile'
import { AccessTimer } from '../../components/AccessTimer'
/**
* HLS плеер, применяется на лайв и завершенных матчах

@ -18,9 +18,10 @@ import { checkUrlParams, getAllUrlParams } from 'helpers/parseUrlParams/parseUrl
import { usePageParams } from 'hooks/usePageParams'
import { useName } from 'features/Name'
import { useAuthStore } from 'features/AuthStore'
import { isPermittedTournament } from '../../helpers/isPermittedTournament'
import { useProfileCard } from '../ProfileCard/hooks'
import { useAuthStore } from '../AuthStore'
import { useBuyMatchPopupStore } from '../BuyMatchPopup'
import { MATCH_CONFIG } from '../BuyMatchPopup/store/hooks/useSubscriptions'
import { prepareMatchProfile } from '../MatchPage/helpers/prepareMatchProfile'

@ -1,5 +1,6 @@
import { AUTH_SERVICE } from '../config/routes'
import { client } from '../config/clients'
import { callApi } from '../helpers'
export const getTokenVirtualUser = async () => {
const url = `${AUTH_SERVICE}/v1/user/create?client_id=${client.auth.clientId}`
@ -8,9 +9,5 @@ export const getTokenVirtualUser = async () => {
method: 'POST',
}
const response = await fetch(url, config)
const body = await response.json()
return body
return callApi({ config, url })
}

Loading…
Cancel
Save