From 985c0710da801aa6b36830be724d6cf1e06d2069 Mon Sep 17 00:00:00 2001 From: Sammers21 Date: Mon, 11 Mar 2024 18:48:38 +0300 Subject: [PATCH] releasef alts on ladder and activity leaderboard --- frontend/src/components/AltsTable/Row.tsx | 10 +- frontend/src/components/AltsTable/index.tsx | 4 + frontend/src/components/DataTable/index.tsx | 5 +- frontend/src/components/TableFilter/index.tsx | 166 ++++----- frontend/src/types/index.ts | 327 +++++++++--------- 5 files changed, 260 insertions(+), 252 deletions(-) diff --git a/frontend/src/components/AltsTable/Row.tsx b/frontend/src/components/AltsTable/Row.tsx index c348079d..65b2d212 100644 --- a/frontend/src/components/AltsTable/Row.tsx +++ b/frontend/src/components/AltsTable/Row.tsx @@ -8,21 +8,25 @@ interface IProps { onRowOver?: (record: any | null) => void; bgColor?: string; shouldHighlight?: boolean; + altHighlight?: boolean; } const Row = ({ record, columns, shouldHighlight, + altHighlight, bgColor, onRowOver, }: IProps) => { - const bgClass = shouldHighlight ? "rgb(21, 128, 61, 0.25)" : ""; - + const href = window.location.href + let bgClass = shouldHighlight ? "rgb(21, 128, 61, 0.25)" : altHighlight ? "rgb(96, 165, 250, 0.25)" : ''; + if(href.indexOf("ladder") > -1 || href.indexOf("shuffle") > -1) { + bgClass = altHighlight ? "rgb(96, 165, 250, 0.25)" : ''; + } const renderDefaultCell = (value: string) => { return {value}; }; - return ( onRowOver && onRowOver(record)} diff --git a/frontend/src/components/AltsTable/index.tsx b/frontend/src/components/AltsTable/index.tsx index d8402bf7..b2d50310 100644 --- a/frontend/src/components/AltsTable/index.tsx +++ b/frontend/src/components/AltsTable/index.tsx @@ -51,8 +51,10 @@ const Table = ({ const rowsComponent = useMemo(() => { function renderRow(record: IActivityRecord, index: number) { let shouldHighlight; + let altHighlight; if (diff === record) { shouldHighlight = true; + altHighlight = true; } else { shouldHighlight = diff && record.diff @@ -60,6 +62,7 @@ const Table = ({ record.diff.won === diff.diff.won && record.diff.lost === diff.diff.lost : false; + altHighlight = record && diff && record.pethash && diff.pethash ? diff.pethash === record.pethash : false; } return ( ); diff --git a/frontend/src/components/DataTable/index.tsx b/frontend/src/components/DataTable/index.tsx index 6d405526..bee20de7 100644 --- a/frontend/src/components/DataTable/index.tsx +++ b/frontend/src/components/DataTable/index.tsx @@ -23,7 +23,7 @@ interface IProps { data: Record | undefined; } -const DataList = ({ data: statistic }: IProps) => { +const DataList = ({ data: statistics }: IProps) => { const { region = REGION.eu, bracket = BRACKETS['3v3'] } = useParams(); const activity = getActivityFromUrl(); const [searchParams] = useSearchParams(); @@ -69,9 +69,8 @@ const DataList = ({ data: statistic }: IProps) => { selectedSpecs={selectedSpecs} onSpecsChange={setSelectedSpecs} bracket={bracket} - statistic={statistic} + statistics={statistics} /> - void; - bracket: string; - statistic: any; -} - -const TableFilter = ({ selectedSpecs, onSpecsChange, bracket, statistic }: IProps) => { - const navigate = useNavigate(); - const location = useLocation(); - const [filtersShown, setFiltersShown] = useState(selectedSpecs.length > 0); - - const toggleFilterShown = () => { - setFiltersShown(!filtersShown); - }; - - const resetFilters = () => { - navigate(location.pathname); - onSpecsChange([]); - }; - - const handleSpecsSelect = (newSpecs: string[]) => { - if (newSpecs.length === 0) { - resetFilters(); - } else { - navigate(location.pathname + '?specs=' + newSpecs.join(',')); - onSpecsChange(newSpecs); - } - }; - - return ( -
-
- - -
- -
-
- {Object.entries(CRESTS_AND_SPECS).map(([crestId, specs]) => { - return ( - - ); - })} -
- -
- -
-
-
- ); -}; - -export default TableFilter; +import { useState } from 'react'; +import { useNavigate, useLocation } from 'react-router-dom'; +import { isEmpty } from 'lodash'; + +import { Button } from '@mui/material'; +import Spec from './Spec'; +import CutOffRating from './CutOffRating'; + +import { CRESTS_AND_SPECS } from '@/constants/filterSchema'; + +interface IProps { + selectedSpecs: string[]; + onSpecsChange: (specs: string[]) => void; + bracket: string; + statistics: any; +} + +const TableFilter = ({ selectedSpecs, onSpecsChange, bracket, statistics: statistic }: IProps) => { + const navigate = useNavigate(); + const location = useLocation(); + const [filtersShown, setFiltersShown] = useState(selectedSpecs.length > 0); + + const toggleFilterShown = () => { + setFiltersShown(!filtersShown); + }; + + const resetFilters = () => { + navigate(location.pathname); + onSpecsChange([]); + }; + + const handleSpecsSelect = (newSpecs: string[]) => { + if (newSpecs.length === 0) { + resetFilters(); + } else { + navigate(location.pathname + '?specs=' + newSpecs.join(',')); + onSpecsChange(newSpecs); + } + }; + + return ( +
+
+ + +
+ +
+
+ {Object.entries(CRESTS_AND_SPECS).map(([crestId, specs]) => { + return ( + + ); + })} +
+ +
+ +
+
+
+ ); +}; + +export default TableFilter; diff --git a/frontend/src/types/index.ts b/frontend/src/types/index.ts index 490c157d..459e5c26 100644 --- a/frontend/src/types/index.ts +++ b/frontend/src/types/index.ts @@ -1,163 +1,164 @@ -interface IAcitivityCharacter { - class: string; - full_spec: string; - race: string; - gender: string; - pos: number; - rating: number; - in_cutoff: boolean; - name: string; - fraction: string; - realm: string; - wins: number; - losses: number; -} - -interface IActivityDiff { - won: number; - lost: number; - rating_diff: number; - rank_diff: number; - last_seen?: string; -} - -export interface IActivityRecord extends IAcitivityCharacter { - character: IAcitivityCharacter; - diff: IActivityDiff; -} - -export interface ITableColumn { - field: string; - label: string; - align?: 'right' | 'left'; - sortable?: boolean; - width?: -1 | number; - render: (record: any) => JSX.Element; -} - -export interface IMetaSpec { - '0.050_presence': number; - '0.050_win_rate': number; - '0.100_presence': number; - '0.100_win_rate': number; - '0.850_presence': number; - '0.850_win_rate': number; - spec_name: string; -} - -export interface IMetaSpecSizing { - '0.050_max': number; - '0.050_min': number; - '0.050_total': number; - '0.100_max': number; - '0.100_min': number; - '0.100_total': number; - - '0.850_max': number; - '0.850_min': number; - '0.850_total': number; -} - -export interface IMeta { - specs: IMetaSpec[]; - specs_sizing?: IMetaSpecSizing; -} - -interface IPlayerMedia { - avatar: string; - insert: string; - main_raw: string; -} - -export interface IPlayerBracket { - bracket_type: string; - rating: number; - - won: number; - lost: number; - rank: number; - - is_rank_one_range: boolean; - season_max_rating: number; - season_max_rating_achieved_timestamp: number; - - max_rating: number; - max_rating_achieved_timestamp: number; - gaming_history: IGamingHistory; -} - -export interface IGamingHistory { - history: IGamingHistoryEntry[]; -} - -export interface IGamingHistoryEntry { - diff: IDiff; - with_who: any[]; - rating?: number; - rank?: number; - character: any; -} - -export interface IHistoryRow { - bracket_type: string; - RANK: IGamingHistoryEntry; - WL: IDiff; - RATING: IGamingHistoryEntry; - WWHO: Array; - timestamp: number; -} - -export interface IDiff { - won: number; - lost: number; - rating_diff: number; - rank_diff: number; - timestamp: number; - last_seen?: string; -} - -interface ISeasons { - name: string; - highest_achievement: { id: number; name: string; completed_timestamp: number }; - rank: string; -} - -export interface IExpansion { - name: string; - seasons: ISeasons[]; -} - -interface ITitleHistory { - expansions: IExpansion[]; -} - -interface IPlayerAchievements { - titles_history: ITitleHistory; -} - -export type IAlt = Exclude; - -export interface IPlayer { - id: number; - name: string; - class: string; - fraction: string; - realm: string; - gender: string; - itemLevel: number; - lastUpdatedUTCms: number; - activeSpec: string; - race: string; - region: string; - talents: string; - - brackets?: IPlayerBracket[]; - media?: IPlayerMedia; - achievements: IPlayerAchievements; - alts?: IAlt[]; - - SHUFFLE?: number; - ARENA_2v2?: number; - ARENA_3v3?: number; - BATTLEGROUNDS?: number; -} +interface IAcitivityCharacter { + class: string; + full_spec: string; + race: string; + gender: string; + pos: number; + rating: number; + in_cutoff: boolean; + name: string; + fraction: string; + realm: string; + wins: number; + losses: number; + pethash: number; +} + +interface IActivityDiff { + won: number; + lost: number; + rating_diff: number; + rank_diff: number; + last_seen?: string; +} + +export interface IActivityRecord extends IAcitivityCharacter { + character: IAcitivityCharacter; + diff: IActivityDiff; +} + +export interface ITableColumn { + field: string; + label: string; + align?: 'right' | 'left'; + sortable?: boolean; + width?: -1 | number; + render: (record: any) => JSX.Element; +} + +export interface IMetaSpec { + '0.050_presence': number; + '0.050_win_rate': number; + '0.100_presence': number; + '0.100_win_rate': number; + '0.850_presence': number; + '0.850_win_rate': number; + spec_name: string; +} + +export interface IMetaSpecSizing { + '0.050_max': number; + '0.050_min': number; + '0.050_total': number; + '0.100_max': number; + '0.100_min': number; + '0.100_total': number; + + '0.850_max': number; + '0.850_min': number; + '0.850_total': number; +} + +export interface IMeta { + specs: IMetaSpec[]; + specs_sizing?: IMetaSpecSizing; +} + +interface IPlayerMedia { + avatar: string; + insert: string; + main_raw: string; +} + +export interface IPlayerBracket { + bracket_type: string; + rating: number; + + won: number; + lost: number; + rank: number; + + is_rank_one_range: boolean; + season_max_rating: number; + season_max_rating_achieved_timestamp: number; + + max_rating: number; + max_rating_achieved_timestamp: number; + gaming_history: IGamingHistory; +} + +export interface IGamingHistory { + history: IGamingHistoryEntry[]; +} + +export interface IGamingHistoryEntry { + diff: IDiff; + with_who: any[]; + rating?: number; + rank?: number; + character: any; +} + +export interface IHistoryRow { + bracket_type: string; + RANK: IGamingHistoryEntry; + WL: IDiff; + RATING: IGamingHistoryEntry; + WWHO: Array; + timestamp: number; +} + +export interface IDiff { + won: number; + lost: number; + rating_diff: number; + rank_diff: number; + timestamp: number; + last_seen?: string; +} + +interface ISeasons { + name: string; + highest_achievement: { id: number; name: string; completed_timestamp: number }; + rank: string; +} + +export interface IExpansion { + name: string; + seasons: ISeasons[]; +} + +interface ITitleHistory { + expansions: IExpansion[]; +} + +interface IPlayerAchievements { + titles_history: ITitleHistory; +} + +export type IAlt = Exclude; + +export interface IPlayer { + id: number; + name: string; + class: string; + fraction: string; + realm: string; + gender: string; + itemLevel: number; + lastUpdatedUTCms: number; + activeSpec: string; + race: string; + region: string; + talents: string; + + brackets?: IPlayerBracket[]; + media?: IPlayerMedia; + achievements: IPlayerAchievements; + alts?: IAlt[]; + + SHUFFLE?: number; + ARENA_2v2?: number; + ARENA_3v3?: number; + BATTLEGROUNDS?: number; +}