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

69 lines
1.8 KiB
TypeScript
Raw Normal View History

2023-08-26 17:26:49 +03:00
import { useMemo } from 'react';
import { useIntl } from 'react-intl';
2023-09-10 20:17:18 +03:00
import DataTable, { createColumnHelper } from '../../components/DataTable';
2023-09-05 00:23:53 +03:00
import { useConceptNavigation } from '../../context/NagivationContext';
2023-09-11 20:31:54 +03:00
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) {
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: 'Обновлена',
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 (
<div className='max-h-[23.8rem] overflow-auto text-sm border w-fit'>
<DataTable dense noFooter
columns={columns}
data={items}
headPosition='0'
2023-09-30 12:47:27 +03:00
enableSorting
initialSorting={{
id: 'time_update',
desc: true
}}
noDataComponent={<div className='h-[10rem]'>Отслеживаемые схемы отсутствуют</div>}
2023-08-26 17:26:49 +03:00
onRowClicked={openRSForm}
/>
</div>);
2023-08-26 17:26:49 +03:00
}
export default ViewSubscriptions;