-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #12 from acm-cmu/meng/misc
Admin Console Changes + Scrimmage Table Timestamps
- Loading branch information
Showing
10 changed files
with
855 additions
and
30 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import { useMemo } from 'react'; | ||
import { | ||
MaterialReactTable, | ||
useMaterialReactTable, | ||
type MRT_ColumnDef, | ||
} from 'material-react-table'; | ||
import { TeamBot } from '@pages/api/admin/admin-bot-history'; | ||
import { AdapterDayjs } from '@mui/x-date-pickers/AdapterDayjs'; | ||
import { LocalizationProvider } from '@mui/x-date-pickers/LocalizationProvider'; | ||
|
||
const DownloadCell = (cell: { row: { original: { bot: any } } }) => { | ||
const { row } = cell; | ||
const url = row.original.bot; | ||
if (url === 'unknown') { | ||
return <div>N/A</div>; | ||
} | ||
return <a href={url}>Download</a>; | ||
}; | ||
|
||
const BotTable = (props: { data: TeamBot[] }) => { | ||
const { data } = props; | ||
const columns = useMemo<MRT_ColumnDef<TeamBot>[]>( | ||
() => [ | ||
{ | ||
accessorKey: 'team', | ||
header: 'Team', | ||
filterVariant: 'autocomplete', | ||
size: 400, | ||
}, | ||
{ | ||
accessorFn: (originalRow) => new Date(originalRow.upload_time), // convert to date for sorting and filtering | ||
id: 'upload_time', | ||
header: 'Upload Time', | ||
filterVariant: 'datetime-range', | ||
Cell: ({ cell }) => cell.getValue<Date>().toLocaleString('en-US'), // convert back to string for display | ||
size: 500, | ||
}, | ||
{ | ||
accessorFn: (originalRow) => originalRow.upload_name, | ||
header: 'Bot', | ||
Cell: DownloadCell, | ||
filterVariant: 'select', | ||
grow: true, | ||
size: 180, | ||
}, | ||
], | ||
[], | ||
); | ||
|
||
const table = useMaterialReactTable({ | ||
columns, | ||
data: data == null ? [] : data, | ||
enableFacetedValues: true, | ||
enableColumnResizing: true, | ||
enableFullScreenToggle: false, | ||
initialState: { showColumnFilters: true }, | ||
}); | ||
|
||
return <MaterialReactTable table={table} />; | ||
}; | ||
|
||
const BotTableWithLocalizationProvider = (props: { data: TeamBot[] }) => { | ||
const { data } = props; | ||
return ( | ||
<LocalizationProvider dateAdapter={AdapterDayjs}> | ||
<BotTable data={data} /> | ||
</LocalizationProvider> | ||
); | ||
}; | ||
|
||
export default BotTableWithLocalizationProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.