diff --git a/src/config/lexics/indexLexics.tsx b/src/config/lexics/indexLexics.tsx index a4c9227f..49684a38 100644 --- a/src/config/lexics/indexLexics.tsx +++ b/src/config/lexics/indexLexics.tsx @@ -5,6 +5,7 @@ import { mailingsLexics } from './mailings' import { sportsLexic } from './sportsLexic' import { landingLexics } from './landingLexics' import { matchDownload } from './matchDownload' +import { statsviewLexics } from './statsviewLexics' const matchPopupLexics = { actions: 1020, @@ -225,4 +226,5 @@ export const indexLexics = { ...sportsPopup, ...landingLexics, ...matchDownload, + ...statsviewLexics, } diff --git a/src/config/lexics/statsviewLexics.tsx b/src/config/lexics/statsviewLexics.tsx new file mode 100644 index 00000000..554fdf23 --- /dev/null +++ b/src/config/lexics/statsviewLexics.tsx @@ -0,0 +1,3 @@ +export const statsviewLexics = { + powered_by: 20210, +} diff --git a/src/config/pages.tsx b/src/config/pages.tsx index a3ca9614..54e162a5 100644 --- a/src/config/pages.tsx +++ b/src/config/pages.tsx @@ -7,6 +7,7 @@ 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 cddfc571..55fc6fb2 100644 --- a/src/features/App/AuthenticatedApp.tsx +++ b/src/features/App/AuthenticatedApp.tsx @@ -41,6 +41,7 @@ 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() @@ -77,6 +78,9 @@ export const AuthenticatedApp = () => { + + + diff --git a/src/features/MatchPage/store/hooks/useTeamsStats.tsx b/src/features/MatchPage/store/hooks/useTeamsStats.tsx index 2e92672d..c59d4d4e 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 } from 'helpers/getLocalStorage' +import { getLocalStorageItem, isMatchPage } from 'helpers' 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, } -type TeamsStats = { +export type TeamsStats = { [teamId: number]: Array, } @@ -73,7 +73,7 @@ export const useTeamsStats = ({ ) const getFirstClickableParam = useCallback((stats: TeamsStats) => { - if (isEmpty(stats)) return null + if (isEmpty(stats) || !isMatchPage()) 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 112456ac..a407749c 100644 --- a/src/features/MatchSidePlaylists/components/TeamsStatsTable/Cell.tsx +++ b/src/features/MatchSidePlaylists/components/TeamsStatsTable/Cell.tsx @@ -31,6 +31,7 @@ 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' @@ -97,7 +98,7 @@ export const Cell = ({ ) const onParamClick = async (param: Param, paramName: string) => { - if (!isClickable(param)) return + if (!isMatchPage() && !isClickable(param)) return disablePlayingEpisodes() @@ -171,7 +172,7 @@ export const Cell = ({ ) : ( onParamClick(teamStatItem.param1, translate(teamStatItem.lexic))} data-param-id={teamStatItem.param1.id} hasValue={Boolean(teamStatItem.param1.val)} @@ -212,7 +213,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 ff5bd97e..b0a72d85 100644 --- a/src/features/MatchSidePlaylists/components/TeamsStatsTable/hooks.tsx +++ b/src/features/MatchSidePlaylists/components/TeamsStatsTable/hooks.tsx @@ -1,12 +1,8 @@ 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 { @@ -17,31 +13,12 @@ export const useTeamsStatsTable = () => { teamsStats, } = useMatchPageStore() - 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 - }, - [], - ) - : []), + const statsLexicIds = useMemo( + () => getStatsLexics({ matchProfile: profile, stats: teamsStats }), [profile, teamsStats], ) - useLexicsConfig(lexicsIds) - - const getStatItemById = (paramId: number) => { - if (!profile) return null - - return find(teamsStats[profile?.team2.id], ({ param1 }) => param1.id === paramId) || null - } + useLexicsConfig(statsLexicIds) useEffect(() => { setCircleAnimation((state) => ({ @@ -52,6 +29,5 @@ 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 dc5f59f6..63de02d5 100644 --- a/src/features/MatchSidePlaylists/components/TeamsStatsTable/index.tsx +++ b/src/features/MatchSidePlaylists/components/TeamsStatsTable/index.tsx @@ -1,23 +1,12 @@ 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 { @@ -28,7 +17,6 @@ export const TeamsStatsTable = () => { const { firstClickableParam, - getStatItemById, } = useTeamsStatsTable() const { isOpen } = useTour() @@ -42,54 +30,11 @@ export const TeamsStatsTable = () => { } return ( - - - -
- - - - - - - - - -
- - - {map(teamsStats[profile.team1.id], (team1StatItem) => { - const team2StatItem = getStatItemById(team1StatItem.param1.id) - - return ( - - - - - - - - - - ) - })} - -
-
-
+ ) } diff --git a/src/pages/StatsView/components/EmbeddedComponent.tsx b/src/pages/StatsView/components/EmbeddedComponent.tsx new file mode 100644 index 00000000..90f4e7bc --- /dev/null +++ b/src/pages/StatsView/components/EmbeddedComponent.tsx @@ -0,0 +1,38 @@ +import styled from 'styled-components/macro' + +import { ButtonSolid, Input } from 'features/Common' + +const EmbedContainer = styled.div` + display: flex; + flex-direction: column; + align-items: center; + max-width: 100%; +` + +const EmbedInput = styled(Input)` + margin: 0; + max-width: 400px; +` + +type EmbedProps = { + url: string, +} + +export const EmbeddedComponent = ({ url }:EmbedProps) => { + const iframeString = `