mirror of
https://github.com/owncast/owncast.git
synced 2024-12-19 07:44:26 +03:00
e50b23d081
* chore(js): be stricter about dead code warnings * chore(js): remove dead code and unused exports * rebase * chore: remove unused files * chore(deps): remove unused prop-types dep * chore(js): remove unused function * chore(deps): remove + check unused deps * chore(js): remove unused exports. Closes #3036
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import { Table } from 'antd';
|
|
import { SortOrder } from 'antd/lib/table/interface';
|
|
import { formatDistanceToNow } from 'date-fns';
|
|
import { FC } from 'react';
|
|
import { User } from '../../types/chat';
|
|
import { formatUAstring } from '../../utils/format';
|
|
|
|
export type ViewerTableProps = {
|
|
data: User[];
|
|
};
|
|
|
|
export const ViewerTable: FC<ViewerTableProps> = ({ data }) => {
|
|
const columns = [
|
|
{
|
|
title: 'User Agent',
|
|
dataIndex: 'userAgent',
|
|
key: 'userAgent',
|
|
render: (ua: string) => formatUAstring(ua),
|
|
},
|
|
{
|
|
title: 'Location',
|
|
dataIndex: 'geo',
|
|
key: 'geo',
|
|
render: geo => (geo ? `${geo.regionName}, ${geo.countryCode}` : '-'),
|
|
},
|
|
{
|
|
title: 'Watch Time',
|
|
dataIndex: 'firstSeen',
|
|
key: 'firstSeen',
|
|
defaultSortOrder: 'ascend' as SortOrder,
|
|
render: (time: Date) => formatDistanceToNow(new Date(time)),
|
|
sorter: (a: any, b: any) => new Date(a.firstSeen).getTime() - new Date(b.firstSeen).getTime(),
|
|
sortDirections: ['descend', 'ascend'] as SortOrder[],
|
|
},
|
|
];
|
|
|
|
return (
|
|
<Table
|
|
pagination={{ hideOnSinglePage: true }}
|
|
className="table-container"
|
|
columns={columns}
|
|
dataSource={data}
|
|
size="small"
|
|
rowKey="id"
|
|
/>
|
|
);
|
|
};
|