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

76 lines
1.8 KiB
TypeScript
Raw Normal View History

'use client';
2023-08-26 17:26:49 +03:00
import { useMemo } from 'react';
import { useIntl } from 'react-intl';
import DataTable, { createColumnHelper } from '@/components/DataTable';
import { useConceptNavigation } from '@/context/NagivationContext';
import { ILibraryItem } from '@/models/library';
2023-08-26 17:26:49 +03:00
interface ViewSubscriptionsProps {
items: ILibraryItem[]
}
const columnHelper = createColumnHelper<ILibraryItem>();
2023-08-26 17:26:49 +03:00
function ViewSubscriptions({items}: ViewSubscriptionsProps) {
const router = useConceptNavigation();
2023-08-26 17:26:49 +03:00
const intl = useIntl();
const openRSForm = (item: ILibraryItem) => router.push(`/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: 'Обновлена',
2023-09-11 21:06:51 +03:00
minSize: 150,
size: 150,
maxSize: 150,
cell: props =>
<div className='min-w-[8.25rem]'>
{new Date(props.cell.getValue()).toLocaleString(intl.locale)}
</div>,
enableSorting: true
})
2023-08-26 17:26:49 +03:00
], [intl]);
return (
<DataTable dense noFooter
2023-12-17 20:19:28 +03:00
className='max-h-[23.8rem] overflow-auto text-sm border'
columns={columns}
data={items}
headPosition='0'
2023-09-30 12:47:27 +03:00
enableSorting
initialSorting={{
id: 'time_update',
desc: true
}}
2023-12-17 20:19:28 +03:00
noDataComponent={
<div className='h-[10rem]'>
Отслеживаемые схемы отсутствуют
</div>
}
2023-08-26 17:26:49 +03:00
onRowClicked={openRSForm}
2023-12-17 20:19:28 +03:00
/>);
2023-08-26 17:26:49 +03:00
}
export default ViewSubscriptions;