Skip to content

Commit 95d47a2

Browse files
committed
Frontend: Show number of online players in match list
1 parent ace501a commit 95d47a2

File tree

2 files changed

+14
-1
lines changed

2 files changed

+14
-1
lines changed

frontend/src/components/MatchList.tsx

+12
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { t } from '../utils/locale';
77
export const MatchTableColumns = [
88
'TEAM_A',
99
'TEAM_B',
10+
'ONLINE_PLAYER_COUNT',
1011
'AGE',
1112
'BEST_OF',
1213
'MATCH_STATE',
@@ -20,6 +21,7 @@ export const MatchTableColumns = [
2021
export const MatchTableColumnLabels: Record<TMatchTableColumns, string> = {
2122
TEAM_A: t('Team A'),
2223
TEAM_B: t('Team B'),
24+
ONLINE_PLAYER_COUNT: t('Online Players'),
2325
AGE: t('Age'),
2426
BEST_OF: t('Best of'),
2527
MATCH_STATE: t('Match State'),
@@ -52,6 +54,9 @@ export const MatchList: Component<{ matches: IMatchResponse[]; columnsToShow: TC
5254
<th>{t('#')}</th>
5355
{cts().TEAM_A && <th>{MatchTableColumnLabels.TEAM_A}</th>}
5456
{cts().TEAM_B && <th>{MatchTableColumnLabels.TEAM_B}</th>}
57+
{cts().ONLINE_PLAYER_COUNT && (
58+
<th>{MatchTableColumnLabels.ONLINE_PLAYER_COUNT}</th>
59+
)}
5560
{cts().AGE && <th>{MatchTableColumnLabels.AGE}</th>}
5661
{cts().BEST_OF && <th>{MatchTableColumnLabels.BEST_OF}</th>}
5762
{cts().MATCH_STATE && <th>{MatchTableColumnLabels.MATCH_STATE}</th>}
@@ -69,6 +74,13 @@ export const MatchList: Component<{ matches: IMatchResponse[]; columnsToShow: TC
6974
<td>{i() + 1}</td>
7075
{cts().TEAM_A && <td>{match.teamA.name}</td>}
7176
{cts().TEAM_B && <td>{match.teamB.name}</td>}
77+
{cts().ONLINE_PLAYER_COUNT && (
78+
<td>
79+
{match.isStopped || match.state === 'FINISHED'
80+
? ''
81+
: match.players.filter((player) => player.online).length}
82+
</td>
83+
)}
7284
{cts().AGE && <td>{diffString(match.createdAt)}</td>}
7385
{cts().BEST_OF && <td>{getTotalNumberOfMaps(match.electionSteps)}</td>}
7486
{cts().MATCH_STATE && <td>{match.state}</td>}

frontend/src/pages/matches.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { useSearchParams } from '@solidjs/router';
22
import { Component, createEffect, For, onCleanup, Show } from 'solid-js';
33
import { createStore } from 'solid-js/store';
44
import { Event, IMatchResponse } from '../../../common';
5+
import { SvgSettings } from '../assets/Icons';
56
import { Card } from '../components/Card';
67
import {
78
MatchList,
@@ -12,11 +13,11 @@ import {
1213
import { createFetcher, getToken } from '../utils/fetcher';
1314
import { t } from '../utils/locale';
1415
import { createWebSocket } from '../utils/webSocket';
15-
import { SvgSettings } from '../assets/Icons';
1616

1717
const defaultColumns: TColumnsToShow = {
1818
TEAM_A: true,
1919
TEAM_B: true,
20+
ONLINE_PLAYER_COUNT: false,
2021
AGE: true,
2122
BEST_OF: true,
2223
MATCH_STATE: true,

0 commit comments

Comments
 (0)