Skip to content

Commit

Permalink
Merge pull request #11 from acm-cmu/meng/misc
Browse files Browse the repository at this point in the history
Display map column in Match History
  • Loading branch information
Meng87 authored Jan 27, 2024
2 parents c930ba3 + 1feadfe commit b22b665
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
16 changes: 11 additions & 5 deletions src/components/MatchTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,33 +18,39 @@ const MatchTable = (props: { data: Match[] }) => {
accessorKey: 'id',
header: 'ID',
filterVariant: 'autocomplete',
size: 100,
size: 80,
},
{
accessorKey: 'player1',
header: 'Team 1',
filterVariant: 'autocomplete',
size: 200,
maxSize: 250,
maxSize: 140,
},
{
accessorKey: 'player2',
header: 'Team 2',
filterVariant: 'autocomplete',
size: 200,
maxSize: 250,
maxSize: 140,
},
{
accessorKey: 'category',
header: 'Category',
filterVariant: 'select',
size: 150,
},
{
accessorKey: 'map',
header: 'Map',
filterVariant: 'multi-select',
size: 150,
},
{
accessorKey: 'status',
header: 'Status',
filterVariant: 'select',
size: 150,
size: 130,
},
{
accessorKey: 'outcome',
Expand All @@ -57,7 +63,7 @@ const MatchTable = (props: { data: Match[] }) => {
header: 'Replay',
Cell: ReplayCell,
filterVariant: 'select',
size: 140,
size: 130,
},
],
[],
Expand Down
2 changes: 2 additions & 0 deletions src/pages/api/admin/admin-match-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface Match {
player1: string;
player2: string;
category: string;
map: string;
status: string;
outcome: string;
replay: string;
Expand Down Expand Up @@ -77,6 +78,7 @@ export default async function handler(
? item.players.L[1].M.teamName.S
: 'unknown',
category: item.category ? item.category.S : 'unknown',
map: item.map && item.map.S ? item.map.S : 'unknown',
status: item.item_status ? item.item_status.S : 'unknown',
outcome: item.placement ? item.placement.N?.toString() : '-1',
replay:
Expand Down
4 changes: 3 additions & 1 deletion src/pages/api/user/match-history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,11 @@ const client = DynamoDBDocument.from(new DynamoDB(config), {
},
});

interface Match {
export interface Match {
id: string;
player: string;
opponent: string;
map: string;
outcome: string;
type: string;
replay: string | null;
Expand Down Expand Up @@ -87,6 +88,7 @@ export default async function handler(
opponent: item.players.L[0].M.current.B
? item.players.L[1].M.teamName.S
: item.players.L[0].M.teamName.S,
map: item.map ? item.map.S : 'Unknown',
outcome: item.placement ? item.placement.N.toString() : 'PENDING',
type: item.category.S,
replay: item.s3_key
Expand Down
13 changes: 3 additions & 10 deletions src/pages/user/scrimmages.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import { useSession } from 'next-auth/react';
import useSWR from 'swr';
import { useState } from 'react';
import { Card, Table, Button } from 'react-bootstrap';
import { Match } from '@pages/api/user/match-history';

import {
DynamoDB,
Expand Down Expand Up @@ -48,16 +49,6 @@ const client = DynamoDBDocument.from(new DynamoDB(config), {
},
});

interface Match {
id: string;
player: string;
opponent: string;
outcome: string;
type: string;
replay: string;
status: string;
}

interface Team {
name: string;
rating: number;
Expand Down Expand Up @@ -85,6 +76,7 @@ const TableRow: React.FC<{ match: Match }> = ({ match }) => {
<tr style={{ backgroundColor }}>
<td>{match.id}</td>
<td>{match.opponent}</td>
<td>{match.map}</td>
<td>{match.status}</td>
<td>{match.outcome}</td>
<td>{match.type}</td>
Expand Down Expand Up @@ -234,6 +226,7 @@ const ScrimmagesTable: React.FC<{ data: Match[] }> = ({ data }) => (
<tr>
<th>Match ID</th>
<th>Opponent</th>
<th>Map</th>
<th>Status</th>
<th>Outcome</th>
<th>Type</th>
Expand Down

0 comments on commit b22b665

Please sign in to comment.