2022-11-28 02:00:28 +00:00
|
|
|
import { History } from 'lucide-react';
|
2022-11-22 12:16:34 +00:00
|
|
|
import { useStore } from 'zustand';
|
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 { useSearchBarState } from '@@/datatables/SearchBar';
|
|
|
|
import { createPersistedStore } from '@@/datatables/types';
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
import { useColumns } from './columns';
|
|
|
|
|
|
|
|
export interface EventsDatatableProps {
|
|
|
|
data: NomadEvent[];
|
|
|
|
isLoading: boolean;
|
|
|
|
}
|
|
|
|
|
2022-11-22 12:16:34 +00:00
|
|
|
const storageKey = 'events';
|
|
|
|
|
|
|
|
const settingsStore = createPersistedStore(storageKey, 'Date');
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
export function EventsDatatable({ data, isLoading }: EventsDatatableProps) {
|
|
|
|
const columns = useColumns();
|
2022-11-22 12:16:34 +00:00
|
|
|
const settings = useStore(settingsStore);
|
|
|
|
const [search, setSearch] = useSearchBarState(storageKey);
|
2022-11-13 10:29:25 +00:00
|
|
|
|
|
|
|
return (
|
2022-11-22 12:16:34 +00:00
|
|
|
<Datatable
|
|
|
|
isLoading={isLoading}
|
|
|
|
columns={columns}
|
|
|
|
dataset={data}
|
|
|
|
initialPageSize={settings.pageSize}
|
|
|
|
onPageSizeChange={settings.setPageSize}
|
|
|
|
initialSortBy={settings.sortBy}
|
|
|
|
onSortByChange={settings.setSortBy}
|
|
|
|
searchValue={search}
|
|
|
|
onSearchChange={setSearch}
|
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
|
|
|
);
|
|
|
|
}
|