diff --git a/src/config/lexics/indexLexics.tsx b/src/config/lexics/indexLexics.tsx
index 49684a38..a4c9227f 100644
--- a/src/config/lexics/indexLexics.tsx
+++ b/src/config/lexics/indexLexics.tsx
@@ -5,7 +5,6 @@ import { mailingsLexics } from './mailings'
import { sportsLexic } from './sportsLexic'
import { landingLexics } from './landingLexics'
import { matchDownload } from './matchDownload'
-import { statsviewLexics } from './statsviewLexics'
const matchPopupLexics = {
actions: 1020,
@@ -226,5 +225,4 @@ export const indexLexics = {
...sportsPopup,
...landingLexics,
...matchDownload,
- ...statsviewLexics,
}
diff --git a/src/config/lexics/statsviewLexics.tsx b/src/config/lexics/statsviewLexics.tsx
deleted file mode 100644
index 554fdf23..00000000
--- a/src/config/lexics/statsviewLexics.tsx
+++ /dev/null
@@ -1,3 +0,0 @@
-export const statsviewLexics = {
- powered_by: 20210,
-}
diff --git a/src/config/pages.tsx b/src/config/pages.tsx
index 54e162a5..a3ca9614 100644
--- a/src/config/pages.tsx
+++ b/src/config/pages.tsx
@@ -7,7 +7,6 @@ export const PAGES = {
mailings: '/useraccount/mailings',
match: '/matches',
player: '/players',
- statsview: '/statsview',
team: '/teams',
thanksForSubscribe: '/thanks-for-subscription',
tournament: '/tournaments',
diff --git a/src/features/App/AuthenticatedApp.tsx b/src/features/App/AuthenticatedApp.tsx
index 55fc6fb2..cddfc571 100644
--- a/src/features/App/AuthenticatedApp.tsx
+++ b/src/features/App/AuthenticatedApp.tsx
@@ -41,7 +41,6 @@ const HighlightsPage = lazy(() => import('pages/HighlightsPage'))
const ThanksPage = lazy(() => import('pages/ThanksPage'))
const Mailings = lazy(() => import('pages/Mailings'))
const FailedPaymeePage = lazy(() => import('pages/FailedPaymeePage'))
-const StatsView = lazy(() => import('pages/StatsView'))
export const AuthenticatedApp = () => {
useSportList()
@@ -78,9 +77,6 @@ export const AuthenticatedApp = () => {
-
-
-
diff --git a/src/features/MatchPage/store/hooks/useTeamsStats.tsx b/src/features/MatchPage/store/hooks/useTeamsStats.tsx
index c59d4d4e..2e92672d 100644
--- a/src/features/MatchPage/store/hooks/useTeamsStats.tsx
+++ b/src/features/MatchPage/store/hooks/useTeamsStats.tsx
@@ -23,7 +23,7 @@ import { getTeamsStats, TeamStatItem } from 'requests'
import { usePageParams } from 'hooks'
-import { getLocalStorageItem, isMatchPage } from 'helpers'
+import { getLocalStorageItem } from 'helpers/getLocalStorage'
import { StatsType, Tabs as StatsTab } from 'features/MatchSidePlaylists/components/TabStats/config'
import { getHalfTime } from 'features/MatchPage/helpers/getHalfTime'
@@ -44,7 +44,7 @@ type UseTeamsStatsArgs = {
statsType: StatsType,
}
-export type TeamsStats = {
+type TeamsStats = {
[teamId: number]: Array,
}
@@ -73,7 +73,7 @@ export const useTeamsStats = ({
)
const getFirstClickableParam = useCallback((stats: TeamsStats) => {
- if (isEmpty(stats) || !isMatchPage()) return null
+ if (isEmpty(stats)) return null
const statItem = (matchProfile?.team1.id && find(
stats[matchProfile.team1.id],
diff --git a/src/features/MatchSidePlaylists/components/TeamsStatsTable/Cell.tsx b/src/features/MatchSidePlaylists/components/TeamsStatsTable/Cell.tsx
index a407749c..112456ac 100644
--- a/src/features/MatchSidePlaylists/components/TeamsStatsTable/Cell.tsx
+++ b/src/features/MatchSidePlaylists/components/TeamsStatsTable/Cell.tsx
@@ -31,7 +31,6 @@ import { useMatchPageStore } from 'features/MatchPage/store'
import { useLexicsStore } from 'features/LexicsStore'
import { Spotlight, Steps } from 'features/MatchTour'
-import { isMatchPage } from 'helpers'
import { StatsType } from '../TabStats/config'
import { CircleAnimationBar } from '../CircleAnimationBar'
@@ -98,7 +97,7 @@ export const Cell = ({
)
const onParamClick = async (param: Param, paramName: string) => {
- if (!isMatchPage() && !isClickable(param)) return
+ if (!isClickable(param)) return
disablePlayingEpisodes()
@@ -172,7 +171,7 @@ export const Cell = ({
)
: (
onParamClick(teamStatItem.param1, translate(teamStatItem.lexic))}
data-param-id={teamStatItem.param1.id}
hasValue={Boolean(teamStatItem.param1.val)}
@@ -213,7 +212,7 @@ export const Cell = ({
/
onParamClick(
teamStatItem.param2!,
translate(teamStatItem.lexic),
diff --git a/src/features/MatchSidePlaylists/components/TeamsStatsTable/hooks.tsx b/src/features/MatchSidePlaylists/components/TeamsStatsTable/hooks.tsx
index b0a72d85..ff5bd97e 100644
--- a/src/features/MatchSidePlaylists/components/TeamsStatsTable/hooks.tsx
+++ b/src/features/MatchSidePlaylists/components/TeamsStatsTable/hooks.tsx
@@ -1,8 +1,12 @@
import { useEffect, useMemo } from 'react'
+import find from 'lodash/find'
+import reduce from 'lodash/reduce'
+
+import type { TeamStatItem } from 'requests'
+
import { useMatchPageStore } from 'features/MatchPage/store'
import { useLexicsConfig } from 'features/LexicsStore'
-import { getStatsLexics } from 'pages/StatsView/helpers'
export const useTeamsStatsTable = () => {
const {
@@ -13,12 +17,31 @@ export const useTeamsStatsTable = () => {
teamsStats,
} = useMatchPageStore()
- const statsLexicIds = useMemo(
- () => getStatsLexics({ matchProfile: profile, stats: teamsStats }),
+ const lexicsIds = useMemo(
+ () => (
+ profile
+ ? reduce>(
+ teamsStats[profile.team1.id],
+ (acc, curr) => {
+ !acc.includes(curr.lexic) && acc.push(curr.lexic)
+ !acc.includes(curr.param1.lexic) && acc.push(curr.param1.lexic)
+ curr.param2 && !acc.includes(curr.param2.lexic) && acc.push(curr.param2.lexic)
+
+ return acc
+ },
+ [],
+ )
+ : []),
[profile, teamsStats],
)
- useLexicsConfig(statsLexicIds)
+ useLexicsConfig(lexicsIds)
+
+ const getStatItemById = (paramId: number) => {
+ if (!profile) return null
+
+ return find(teamsStats[profile?.team2.id], ({ param1 }) => param1.id === paramId) || null
+ }
useEffect(() => {
setCircleAnimation((state) => ({
@@ -29,5 +52,6 @@ export const useTeamsStatsTable = () => {
return {
firstClickableParam: getFirstClickableParam(teamsStats),
+ getStatItemById,
}
}
diff --git a/src/features/MatchSidePlaylists/components/TeamsStatsTable/index.tsx b/src/features/MatchSidePlaylists/components/TeamsStatsTable/index.tsx
index 63de02d5..dc5f59f6 100644
--- a/src/features/MatchSidePlaylists/components/TeamsStatsTable/index.tsx
+++ b/src/features/MatchSidePlaylists/components/TeamsStatsTable/index.tsx
@@ -1,12 +1,23 @@
import { useTour } from '@reactour/tour'
+import map from 'lodash/map'
+
import { useMatchPageStore } from 'features/MatchPage/store'
import { Loader } from 'features/Loader'
import { defaultTheme } from 'features/Theme/config'
-import { StatsTable } from 'pages/StatsView/components/StatsTable'
-
import { useTeamsStatsTable } from './hooks'
+import { Cell } from './Cell'
+import {
+ Container,
+ TableWrapper,
+ Table,
+ Header,
+ Row,
+ CellContainer,
+ TeamShortName,
+ StatItemTitle,
+} from './styled'
export const TeamsStatsTable = () => {
const {
@@ -17,6 +28,7 @@ export const TeamsStatsTable = () => {
const {
firstClickableParam,
+ getStatItemById,
} = useTeamsStatsTable()
const { isOpen } = useTour()
@@ -30,11 +42,54 @@ export const TeamsStatsTable = () => {
}
return (
-
+
+
+
+
+
+
+ {map(teamsStats[profile.team1.id], (team1StatItem) => {
+ const team2StatItem = getStatItemById(team1StatItem.param1.id)
+
+ return (
+
+ |
+
+
+
+
+
+ |
+
+ )
+ })}
+
+
+
+
)
}
diff --git a/src/pages/StatsView/components/StatsTable.tsx b/src/pages/StatsView/components/StatsTable.tsx
deleted file mode 100644
index 2fb33c21..00000000
--- a/src/pages/StatsView/components/StatsTable.tsx
+++ /dev/null
@@ -1,90 +0,0 @@
-import map from 'lodash/map'
-
-import { MatchInfo, Param } from 'requests'
-
-import {
- CellContainer,
- Container,
- Header,
- Row,
- StatItemTitle,
- Table,
- TableWrapper,
- TeamShortName,
-} from 'features/MatchSidePlaylists/components/TeamsStatsTable/styled'
-import { Cell } from 'features/MatchSidePlaylists/components/TeamsStatsTable/Cell'
-
-import { TeamsStats } from 'features/MatchPage/store/hooks/useTeamsStats'
-
-import { getStatItemById } from '../helpers'
-
-type StatsTableProps = {
- firstClickableParam?: Param | null,
- isOpen?: boolean,
- profile: MatchInfo,
- teamsStats: TeamsStats,
-}
-export const StatsTable = ({
- firstClickableParam = null,
- isOpen = false,
- profile,
- teamsStats,
-}: StatsTableProps) => {
- if (!profile) return null
-
- return (
-
-
-
-
-
-
- {map(teamsStats[profile.team1.id], (team1StatItem) => {
- const team2StatItem = getStatItemById({
- matchProfile: profile,
- paramId: team1StatItem.param1.id,
- stats: teamsStats,
- })
-
- return (
-
- |
-
-
-
-
-
- |
-
- )
- })}
-
-
-
-
- )
-}
diff --git a/src/pages/StatsView/helpers/getStatsItem.tsx b/src/pages/StatsView/helpers/getStatsItem.tsx
deleted file mode 100644
index f03e283b..00000000
--- a/src/pages/StatsView/helpers/getStatsItem.tsx
+++ /dev/null
@@ -1,16 +0,0 @@
-import { TeamStatItem } from 'requests'
-import { StatsLexicType } from './getStatsLexic'
-
-type StatsItemType = StatsLexicType & {
- paramId: number,
-}
-export const getStatItemById = ({
- matchProfile,
- paramId,
- stats,
-}: StatsItemType) => {
- if (!matchProfile) return null
-
- return stats[matchProfile?.team2.id]
- .find(({ param1 }: TeamStatItem) => param1.id === paramId) || null
-}
diff --git a/src/pages/StatsView/helpers/getStatsLexic.tsx b/src/pages/StatsView/helpers/getStatsLexic.tsx
deleted file mode 100644
index d2f96e46..00000000
--- a/src/pages/StatsView/helpers/getStatsLexic.tsx
+++ /dev/null
@@ -1,22 +0,0 @@
-import reduce from 'lodash/reduce'
-import { MatchInfo, TeamStatItem } from 'requests'
-import { TeamsStats } from 'features/MatchPage/store/hooks/useTeamsStats'
-
-export type StatsLexicType = {
- matchProfile: MatchInfo,
- stats: TeamsStats,
-}
-export const getStatsLexics = ({ matchProfile, stats }: StatsLexicType) => (
- matchProfile
- ? reduce>(
- stats[matchProfile.team1.id],
- (acc, curr) => {
- !acc.includes(curr.lexic) && acc.push(curr.lexic)
- !acc.includes(curr.param1.lexic) && acc.push(curr.param1.lexic)
- curr.param2 && !acc.includes(curr.param2.lexic) && acc.push(curr.param2.lexic)
-
- return acc
- },
- [],
- )
- : [])
diff --git a/src/pages/StatsView/helpers/index.tsx b/src/pages/StatsView/helpers/index.tsx
deleted file mode 100644
index 97f38ade..00000000
--- a/src/pages/StatsView/helpers/index.tsx
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from './getStatsLexic'
-export * from './getStatsItem'
diff --git a/src/pages/StatsView/hooks.tsx b/src/pages/StatsView/hooks.tsx
deleted file mode 100644
index 75b387d3..00000000
--- a/src/pages/StatsView/hooks.tsx
+++ /dev/null
@@ -1,78 +0,0 @@
-import {
- useEffect,
- useMemo,
- useState,
-} from 'react'
-
-import {
- getMatchInfo,
- getTeamsStats,
- MatchInfo,
-} from 'requests'
-
-import { useInterval, usePageParams } from 'hooks'
-
-import { TeamsStats } from 'features/MatchPage/store/hooks/useTeamsStats'
-import { useLexicsConfig } from 'features/LexicsStore'
-
-import { getStatsLexics } from 'pages/StatsView/helpers'
-
-const INTERVAL_FETCH_STATS = 30 * 1000
-
-export const useStatsView = () => {
- const [matchProfile, setMatchProfile] = useState(null)
- const [stats, setStats] = useState({})
- const {
- profileId,
- sportName,
- sportType,
- } = usePageParams()
-
- const fetchMatchInfo = async () => {
- if (!sportName || !profileId) return
-
- const profile = await getMatchInfo(sportType, profileId)
- setMatchProfile(profile)
- }
-
- const fetchStats = async () => {
- if (!sportName || !profileId) return
-
- const statistic = await getTeamsStats({
- matchId: profileId,
- sportName,
- })
- setStats(statistic)
- }
-
- const statsLexicIds = useMemo(
- () => getStatsLexics({ matchProfile, stats }),
- [matchProfile, stats],
- )
-
- useLexicsConfig(statsLexicIds)
-
- const { start, stop } = useInterval({
- callback: fetchStats,
- intervalDuration: INTERVAL_FETCH_STATS,
- startImmediate: true,
- })
-
- useEffect(() => {
- if (!sportName || !profileId) return undefined
-
- start()
- fetchMatchInfo()
-
- return () => stop()
- // eslint-disable-next-line react-hooks/exhaustive-deps
- }, [
- profileId,
- sportName,
- ])
-
- return {
- matchProfile,
- teamsStats: stats,
- }
-}
diff --git a/src/pages/StatsView/index.tsx b/src/pages/StatsView/index.tsx
deleted file mode 100644
index e9a6c8dc..00000000
--- a/src/pages/StatsView/index.tsx
+++ /dev/null
@@ -1,35 +0,0 @@
-import { Logo } from 'features/Logo'
-import { T9n } from 'features/T9n'
-
-import { useStatsView } from './hooks'
-import { StatsTable } from './components/StatsTable'
-import { Powered, Container } from './styled'
-
-const StatsView = () => {
- const { matchProfile, teamsStats } = useStatsView()
-
- return (
-
-
-
- {matchProfile?.team1 && matchProfile?.team2 && (
-
- )}
-
-
-
- )
-}
-
-export default StatsView
diff --git a/src/pages/StatsView/styled.tsx b/src/pages/StatsView/styled.tsx
deleted file mode 100644
index b3d2eef9..00000000
--- a/src/pages/StatsView/styled.tsx
+++ /dev/null
@@ -1,25 +0,0 @@
-import styled from 'styled-components/macro'
-
-export const Powered = styled.span`
- display: block;
- text-decoration: none;
- font-size: 12px;
- line-height: 20px;
-
- text-align: center;
- letter-spacing: -0.32px;
-
- color: #76ADFF;
-`
-
-export const Container = styled.div`
- display: flex;
- flex-direction: column;
- gap: 15px;
- padding: 25px 5px 15px 5px;
-
- .header__logo{
- display: flex;
- justify-content: center;
- }
-`
diff --git a/src/requests/getTeamsStats.tsx b/src/requests/getTeamsStats.tsx
index ef9269de..ec8fd690 100644
--- a/src/requests/getTeamsStats.tsx
+++ b/src/requests/getTeamsStats.tsx
@@ -25,13 +25,13 @@ export type TeamStatItem = {
}
type Response = {
- data?: TeamsType,
+ data?: {
+ [teamId: string]: Array,
+ },
error?: string,
message?: string,
}
-export type TeamsType = Record>
-
type GetTeamsStatsArgs = {
matchId: number,
period?: number,