Skip to content

Commit 7544ca8

Browse files
authored
Merge pull request #95 from CastledChess/fix/history-page
fix(history-page): delete column move, use date_fns, and change result
2 parents 9a0e762 + 2eda361 commit 7544ca8

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

src/pages/history/columns.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ export interface GameDetails {
2626
Result: string;
2727
Date: string;
2828
Round: string;
29+
Termination: string;
2930
};
3031
id: string;
3132
pgn: string;

src/pages/history/data-table.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import {
99
useReactTable,
1010
getPaginationRowModel,
1111
getSortedRowModel,
12-
} from '@tanstack/react-table';
13-
import Moment from 'moment';
12+
} from '@tanstack/react-table';;
1413
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table';
1514
import { useTranslation } from 'react-i18next';
1615
import { GameDetails } from './columns';
16+
import { format, parse } from 'date-fns';
1717

1818
interface DataTableProps<TData> {
1919
columns: ColumnDef<TData>[];
@@ -56,7 +56,7 @@ export function DataTable<TData extends GameDetails>({ columns, data }: DataTabl
5656
{header.column.id === 'header_Result'
5757
? flexRender(header.column.columnDef.header, header.getContext())
5858
: null}
59-
{header.column.id === 'moves' ? t(String(header.column.id).toLowerCase()) : null}
59+
{/* {header.column.id === 'moves' ? t(String(header.column.id).toLowerCase()) : null} */}
6060
{header.column.id === 'header_Date' ? t('date') : null}
6161
</TableHead>
6262
);
@@ -73,12 +73,10 @@ export function DataTable<TData extends GameDetails>({ columns, data }: DataTabl
7373
{cell.column.id === 'select' ? flexRender(cell.column.columnDef.cell, cell.getContext()) : null}
7474
{cell.column.id === 'players' ? flexRender(cell.column.columnDef.cell, cell.getContext()) : null}
7575
{cell.column.id === 'header_Result'
76-
? t(String(cell.row.original.header.Result).toLowerCase())
77-
: null}
78-
{cell.column.id === 'moves' ? cell.row.original.header.Round : null}
79-
{cell.column.id === 'header_Date'
80-
? Moment(cell.row.original.header.Date).format(' DD / MM / YYYY')
76+
? t(String(cell.row.original.header.Termination).toLowerCase())
8177
: null}
78+
{/* {cell.column.id === 'moves' ? cell.row.original.header.Round : null} */}
79+
{cell.column.id === 'header_Date' ? format(parse(cell.row.original.header.Date, 'yyyy.MM.dd', new Date()), 'dd / MM / yyyy') : null}
8280
{cell.column.id === 'actions' ? flexRender(cell.column.columnDef.cell, cell.getContext()) : null}
8381
</TableCell>
8482
))}

0 commit comments

Comments
 (0)