ConceptPortal-public/rsconcept/frontend/src/pages/UserProfilePage/ViewSubscriptions.tsx

69 lines
1.7 KiB
TypeScript
Raw Normal View History

import { createColumnHelper } from '@tanstack/react-table';
2023-08-26 17:26:49 +03:00
import { useMemo } from 'react';
import { useIntl } from 'react-intl';
import DataTable from '../../components/Common/DataTable';
2023-09-05 00:23:53 +03:00
import { useConceptNavigation } from '../../context/NagivationContext';
2023-08-26 17:26:49 +03:00
import { ILibraryItem } from '../../utils/models';
interface ViewSubscriptionsProps {
items: ILibraryItem[]
}
const columnHelper = createColumnHelper<ILibraryItem>();
2023-08-26 17:26:49 +03:00
function ViewSubscriptions({items}: ViewSubscriptionsProps) {
2023-09-05 00:23:53 +03:00
const { navigateTo } = useConceptNavigation();
2023-08-26 17:26:49 +03:00
const intl = useIntl();
2023-09-05 00:23:53 +03:00
const openRSForm = (item: ILibraryItem) => navigateTo(`/rsforms/${item.id}`);
2023-08-26 17:26:49 +03:00
const columns = useMemo(() =>
[
columnHelper.accessor('alias', {
2023-08-26 17:26:49 +03:00
id: 'alias',
header: 'Шифр',
size: 200,
minSize: 200,
maxSize: 200,
enableSorting: true
}),
columnHelper.accessor('title', {
2023-08-26 17:26:49 +03:00
id: 'title',
header: 'Название',
minSize: 200,
size: 800,
maxSize: 800,
enableSorting: true
}),
columnHelper.accessor('time_update', {
2023-08-26 17:26:49 +03:00
id: 'time_update',
header: 'Обновлена',
minSize: 200,
size: 200,
maxSize: 200,
cell: props => new Date(props.cell.getValue()).toLocaleString(intl.locale),
enableSorting: true
})
2023-08-26 17:26:49 +03:00
], [intl]);
return (
<div className='h-full overflow-auto text-sm border w-fit'>
<DataTable
2023-08-26 17:26:49 +03:00
columns={columns}
data={items}
// defaultSortFieldId='time_update'
// defaultSortAsc={false}
2023-08-26 17:26:49 +03:00
noDataComponent={
<div className='h-[10rem]'>Отслеживаемые схемы отсутствуют</div>
}
onRowClicked={openRSForm}
/>
</div>
2023-08-26 17:26:49 +03:00
)
}
export default ViewSubscriptions;