2022-11-28 02:00:28 +00:00
|
|
|
import { History } from 'lucide-react';
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
import { NomadEvent } from '@/react/nomad/types';
|
|
|
|
|
2022-11-22 12:16:34 +00:00
|
|
|
import { Datatable } from '@@/datatables';
|
|
|
|
import { createPersistedStore } from '@@/datatables/types';
|
2023-05-02 06:42:16 +00:00
|
|
|
import { useTableState } from '@@/datatables/useTableState';
|
2022-11-13 10:29:25 +00:00
|
|
|
|
2023-05-02 06:42:16 +00:00
|
|
|
import { columns } from './columns';
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
export interface EventsDatatableProps {
|
|
|
|
data: NomadEvent[];
|
|
|
|
isLoading: boolean;
|
|
|
|
}
|
|
|
|
|
2023-05-02 06:42:16 +00:00
|
|
|
const storageKey = 'nomad_events';
|
2022-11-22 12:16:34 +00:00
|
|
|
|
2023-05-02 06:42:16 +00:00
|
|
|
const settingsStore = createPersistedStore(storageKey, 'date');
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
export function EventsDatatable({ data, isLoading }: EventsDatatableProps) {
|
2023-05-02 06:42:16 +00:00
|
|
|
const tableState = useTableState(settingsStore, storageKey);
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
return (
|
2022-11-22 12:16:34 +00:00
|
|
|
<Datatable
|
|
|
|
isLoading={isLoading}
|
2023-05-02 06:42:16 +00:00
|
|
|
settingsManager={tableState}
|
2022-11-22 12:16:34 +00:00
|
|
|
columns={columns}
|
|
|
|
dataset={data}
|
2022-11-28 02:00:28 +00:00
|
|
|
titleIcon={History}
|
2022-11-22 12:16:34 +00:00
|
|
|
title="Events"
|
|
|
|
totalCount={data.length}
|
|
|
|
getRowId={(row) => `${row.Date}-${row.Message}-${row.Type}`}
|
|
|
|
disableSelect
|
|
|
|
/>
|
2022-11-13 10:29:25 +00:00
|
|
|
);
|
|
|
|
}
|