Skip to content

Commit

Permalink
Frontend: Show number of online players in match list
Browse files Browse the repository at this point in the history
  • Loading branch information
JensForstmann committed Apr 22, 2024
1 parent ace501a commit 95d47a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
12 changes: 12 additions & 0 deletions frontend/src/components/MatchList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { t } from '../utils/locale';
export const MatchTableColumns = [
'TEAM_A',
'TEAM_B',
'ONLINE_PLAYER_COUNT',
'AGE',
'BEST_OF',
'MATCH_STATE',
Expand All @@ -20,6 +21,7 @@ export const MatchTableColumns = [
export const MatchTableColumnLabels: Record<TMatchTableColumns, string> = {
TEAM_A: t('Team A'),
TEAM_B: t('Team B'),
ONLINE_PLAYER_COUNT: t('Online Players'),
AGE: t('Age'),
BEST_OF: t('Best of'),
MATCH_STATE: t('Match State'),
Expand Down Expand Up @@ -52,6 +54,9 @@ export const MatchList: Component<{ matches: IMatchResponse[]; columnsToShow: TC
<th>{t('#')}</th>
{cts().TEAM_A && <th>{MatchTableColumnLabels.TEAM_A}</th>}
{cts().TEAM_B && <th>{MatchTableColumnLabels.TEAM_B}</th>}
{cts().ONLINE_PLAYER_COUNT && (
<th>{MatchTableColumnLabels.ONLINE_PLAYER_COUNT}</th>
)}
{cts().AGE && <th>{MatchTableColumnLabels.AGE}</th>}
{cts().BEST_OF && <th>{MatchTableColumnLabels.BEST_OF}</th>}
{cts().MATCH_STATE && <th>{MatchTableColumnLabels.MATCH_STATE}</th>}
Expand All @@ -69,6 +74,13 @@ export const MatchList: Component<{ matches: IMatchResponse[]; columnsToShow: TC
<td>{i() + 1}</td>
{cts().TEAM_A && <td>{match.teamA.name}</td>}
{cts().TEAM_B && <td>{match.teamB.name}</td>}
{cts().ONLINE_PLAYER_COUNT && (
<td>
{match.isStopped || match.state === 'FINISHED'
? ''
: match.players.filter((player) => player.online).length}
</td>
)}
{cts().AGE && <td>{diffString(match.createdAt)}</td>}
{cts().BEST_OF && <td>{getTotalNumberOfMaps(match.electionSteps)}</td>}
{cts().MATCH_STATE && <td>{match.state}</td>}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/pages/matches.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useSearchParams } from '@solidjs/router';
import { Component, createEffect, For, onCleanup, Show } from 'solid-js';
import { createStore } from 'solid-js/store';
import { Event, IMatchResponse } from '../../../common';
import { SvgSettings } from '../assets/Icons';
import { Card } from '../components/Card';
import {
MatchList,
Expand All @@ -12,11 +13,11 @@ import {
import { createFetcher, getToken } from '../utils/fetcher';
import { t } from '../utils/locale';
import { createWebSocket } from '../utils/webSocket';
import { SvgSettings } from '../assets/Icons';

const defaultColumns: TColumnsToShow = {
TEAM_A: true,
TEAM_B: true,
ONLINE_PLAYER_COUNT: false,
AGE: true,
BEST_OF: true,
MATCH_STATE: true,
Expand Down

0 comments on commit 95d47a2

Please sign in to comment.