Ott 1710 disable preferences on facr (#510)

* refactor(1710): replaced hooks usePageId useSportNameParam to usePageParams

* feat(1710): added config to disable preferencse
keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 4 years ago
parent 590ab5e390
commit 53e0abae2d
  1. 1
      src/config/clients/facr.tsx
  2. 1
      src/config/clients/types.tsx
  3. 10
      src/features/MatchPage/components/FinishedMatch/hooks/index.tsx
  4. 5
      src/features/MatchPage/components/FinishedMatch/hooks/useChapters.tsx
  5. 5
      src/features/MatchPage/components/FinishedMatch/hooks/useEpisodes.tsx
  6. 4
      src/features/MatchPage/components/MatchProfileCard/index.tsx
  7. 10
      src/features/MatchPage/hooks/useLastPlayPosition.tsx
  8. 10
      src/features/MatchPage/hooks/useMatchProfile.tsx
  9. 10
      src/features/MatchPage/hooks/usePlayerProgressReporter.tsx
  10. 5
      src/features/Menu/index.tsx
  11. 5
      src/features/PlayerPage/hooks.tsx
  12. 4
      src/features/PreferencesPopup/store/hooks/index.tsx
  13. 5
      src/features/TeamPage/hooks.tsx
  14. 5
      src/features/TournamentPage/hooks.tsx
  15. 2
      src/hooks/index.tsx
  16. 13
      src/hooks/usePageId.tsx
  17. 16
      src/hooks/useSportNameParam.tsx

@ -13,6 +13,7 @@ export const facr: ClientConfig = {
metaDataUrlParams: `?hash=${randomHash()}`,
},
defaultLanguage: 'cs',
disabledPreferences: true,
requests: {
[PROCEDURES.get_matches]: params,
[PROCEDURES.get_team_matches]: params,

@ -9,6 +9,7 @@ export type ClientConfig = {
metaDataUrlParams?: string,
},
defaultLanguage?: Languages,
disabledPreferences?: boolean,
requests?: Record<ProcedureName, RequestParameters>,
styles: {
background?: string,

@ -2,11 +2,8 @@ import { useEffect } from 'react'
import type { MatchInfo } from 'requests'
import {
useSportNameParam,
usePageId,
useToggle,
} from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import { useToggle } from 'hooks/useToggle'
import type { Settings } from 'features/MatchPopup'
import { useMatchPopupStore } from 'features/MatchPopup'
@ -29,8 +26,7 @@ export const useFinishedMatch = ({ profile }: Props) => {
setMatch,
setSettings,
} = useMatchPopupStore()
const { sportType } = useSportNameParam()
const matchId = usePageId()
const { profileId: matchId, sportType } = usePageParams()
const {
close: closeSettingsPopup,
isOpen: isSettingsPopupOpen,

@ -7,7 +7,7 @@ import {
import type { Episodes, Videos } from 'requests'
import { getVideos } from 'requests'
import { usePageId, useSportNameParam } from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import type { PlaylistOption } from 'features/MatchPage/types'
@ -23,8 +23,7 @@ export const useChapters = ({
selectedPlaylist,
}: Args) => {
const [videos, setVideos] = useState<Videos>([])
const { sportType } = useSportNameParam()
const matchId = usePageId()
const { profileId: matchId, sportType } = usePageParams()
useEffect(() => {
getVideos(sportType, matchId).then(setVideos)

@ -9,7 +9,7 @@ import isEmpty from 'lodash/isEmpty'
import type { Episodes } from 'requests'
import { getPlayerPlaylists } from 'requests'
import { usePageId, useSportNameParam } from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import { PlaylistOption, PlaylistTypes } from 'features/MatchPage/types'
import {
@ -26,8 +26,7 @@ export const useEpisodes = () => {
settings,
} = useMatchPopupStore()
const [episodes, setEpisodes] = useState<Episodes>([])
const { sportType } = useSportNameParam()
const matchId = usePageId()
const { profileId: matchId, sportType } = usePageParams()
const fetchEpisodes = useCallback((
playlistOption: PlaylistOption,

@ -5,7 +5,7 @@ import { ProfileTypes } from 'config'
import { useMatchSwitchesStore } from 'features/MatchSwitches'
import { Name } from 'features/Name'
import { useSportNameParam } from 'hooks/useSportNameParam'
import { usePageParams } from 'hooks/usePageParams'
import {
Wrapper,
@ -21,7 +21,7 @@ type Props = {
}
export const MatchProfileCard = ({ profile }: Props) => {
const { sportType } = useSportNameParam()
const { sportType } = usePageParams()
const { isScoreHidden } = useMatchSwitchesStore()
if (!profile) return <Wrapper />

@ -3,11 +3,8 @@ import { useEffect, useState } from 'react'
import type { LastPlayPosition } from 'requests'
import { getMatchLastWatchSeconds } from 'requests'
import {
useSportNameParam,
usePageId,
useRequest,
} from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import { useRequest } from 'hooks/useRequest'
const initialPosition = {
half: 0,
@ -15,8 +12,7 @@ const initialPosition = {
}
export const useLastPlayPosition = () => {
const { sportType } = useSportNameParam()
const matchId = usePageId()
const { profileId: matchId, sportType } = usePageParams()
const [
lastPlayPosition,
setPosition,

@ -7,18 +7,14 @@ import {
import type { MatchInfo } from 'requests'
import { getMatchInfo } from 'requests'
import {
useSportNameParam,
useInterval,
usePageId,
} from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import { useInterval } from 'hooks/useInterval'
import { MATCH_UPDATE_INTERVAL } from '../config'
export const useMatchProfile = () => {
const [matchProfile, setMatchProfile] = useState<MatchInfo>(null)
const { sportType } = useSportNameParam()
const matchId = usePageId()
const { profileId: matchId, sportType } = usePageParams()
const fetchMatchProfile = useCallback(() => {
getMatchInfo(sportType, matchId).then(setMatchProfile)

@ -2,17 +2,13 @@ import { useCallback, useRef } from 'react'
import { reportPlayerProgress } from 'requests'
import {
useSportNameParam,
usePageId,
useInterval,
} from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import { useInterval } from 'hooks/useInterval'
const reportRequestInterval = 30000
export const usePlayerProgressReporter = () => {
const { sportType } = useSportNameParam()
const matchId = usePageId()
const { profileId: matchId, sportType } = usePageParams()
const playerData = useRef({ period: 0, seconds: 0 })
const intervalCallback = () => {

@ -1,7 +1,8 @@
import { Link, useRouteMatch } from 'react-router-dom'
import { PAGES } from 'config'
import { isMobileDevice } from 'config/userAgent'
import { client } from 'config/clients'
import { PAGES } from 'config/pages'
import { usePreferencesStore } from 'features/PreferencesPopup'
@ -20,7 +21,7 @@ export const Menu = () => {
<MenuList>
{isMobileDevice && <FavoritesMobilePopup />}
{
isHomePage && (
isHomePage && !client.disabledPreferences && (
<MenuItem onClick={openPopup}>
<Icon src='header-settings' size='1.4rem' />
</MenuItem>

@ -4,15 +4,14 @@ import {
useCallback,
} from 'react'
import { useSportNameParam, usePageId } from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import type { PlayerProfile } from 'requests/getPlayerInfo'
import { getPlayerInfo, getPlayerMatches } from 'requests'
export const usePlayerPage = () => {
const [playerProfile, setPlayerProfile] = useState<PlayerProfile>(null)
const { sportType } = useSportNameParam()
const playerId = usePageId()
const { profileId: playerId, sportType } = usePageParams()
const {
firstname_eng = '',

@ -4,6 +4,8 @@ import isBoolean from 'lodash/isBoolean'
import uniq from 'lodash/uniq'
import map from 'lodash/map'
import { client } from 'config/clients'
import { useLocalStore, useToggle } from 'hooks'
import { useTournamentsBySports } from './useTournamentsBySports'
@ -14,7 +16,7 @@ import { useSearch } from './useSearch'
export const usePreferences = () => {
const [firstLoad, setFirstLoad] = useLocalStore({
defaultValue: true,
defaultValue: !client.disabledPreferences,
key: 'preferences_first_load',
validator: isBoolean,
})

@ -7,12 +7,11 @@ import {
import type { TeamInfo } from 'requests'
import { getTeamInfo, getTeamMatches } from 'requests'
import { useSportNameParam, usePageId } from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
export const useTeamPage = () => {
const [teamProfile, setTeamProfile] = useState<TeamInfo>(null)
const { sportType } = useSportNameParam()
const teamId = usePageId()
const { profileId: teamId, sportType } = usePageParams()
useEffect(() => {
getTeamInfo(sportType, teamId)

@ -7,14 +7,13 @@ import {
import type { TournamentInfo } from 'requests'
import { getTournamentInfo, getTournamentMatches } from 'requests'
import { useSportNameParam, usePageId } from 'hooks'
import { usePageParams } from 'hooks/usePageParams'
import { useName } from 'features/Name'
export const useTournamentPage = () => {
const [tournamentProfile, setTournamentProfile] = useState<TournamentInfo>(null)
const { sportType } = useSportNameParam()
const tournamentId = usePageId()
const { profileId: tournamentId, sportType } = usePageParams()
const country = useName(tournamentProfile?.country || {})
useEffect(() => {

@ -1,7 +1,5 @@
export * from './usePageId'
export * from './useToggle'
export * from './useRequest'
export * from './useSportNameParam'
export * from './useStorage'
export * from './useInterval'
export * from './useEventListener'

@ -1,13 +0,0 @@
import { useParams } from 'react-router-dom'
type Params = {
pageId: string,
}
/**
* Хук возвращает id страницы
*/
export const usePageId = () => {
const { pageId } = useParams<Params>()
return Number(pageId)
}

@ -1,16 +0,0 @@
import { useParams } from 'react-router'
import toUpper from 'lodash/toUpper'
import { SportTypes } from 'config'
type SportName = 'FOOTBALL' | 'HOCKEY' | 'BASKETBALL'
export const useSportNameParam = () => {
const { sportName } = useParams<{ sportName: string }>()
return {
sportName,
sportType: SportTypes[toUpper(sportName) as SportName],
}
}
Loading…
Cancel
Save