2023-12-13 14:32:57 +03:00
|
|
|
|
'use client';
|
|
|
|
|
|
2023-12-25 16:53:27 +03:00
|
|
|
|
import { motion } from 'framer-motion';
|
2023-08-26 17:26:49 +03:00
|
|
|
|
import { useMemo } from 'react';
|
|
|
|
|
import { useIntl } from 'react-intl';
|
|
|
|
|
|
2023-12-13 14:32:57 +03:00
|
|
|
|
import DataTable, { createColumnHelper } from '@/components/DataTable';
|
2023-12-26 14:23:51 +03:00
|
|
|
|
import { useConceptNavigation } from '@/context/NavigationContext';
|
2023-12-13 14:32:57 +03:00
|
|
|
|
import { ILibraryItem } from '@/models/library';
|
2024-01-06 03:15:02 +03:00
|
|
|
|
import { animateSideView } from '@/styling/animations';
|
2023-08-26 17:26:49 +03:00
|
|
|
|
|
|
|
|
|
interface ViewSubscriptionsProps {
|
2023-12-28 14:04:44 +03:00
|
|
|
|
items: ILibraryItem[];
|
2023-08-26 17:26:49 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-09-09 20:36:55 +03:00
|
|
|
|
const columnHelper = createColumnHelper<ILibraryItem>();
|
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
|
function ViewSubscriptions({ items }: ViewSubscriptionsProps) {
|
2023-12-13 14:32:57 +03:00
|
|
|
|
const router = useConceptNavigation();
|
2023-08-26 17:26:49 +03:00
|
|
|
|
const intl = useIntl();
|
|
|
|
|
|
2023-12-13 14:32:57 +03:00
|
|
|
|
const openRSForm = (item: ILibraryItem) => router.push(`/rsforms/${item.id}`);
|
2023-08-26 17:26:49 +03:00
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
|
const columns = useMemo(
|
|
|
|
|
() => [
|
|
|
|
|
columnHelper.accessor('alias', {
|
|
|
|
|
id: 'alias',
|
|
|
|
|
header: 'Шифр',
|
|
|
|
|
size: 200,
|
|
|
|
|
minSize: 200,
|
|
|
|
|
maxSize: 200,
|
|
|
|
|
enableSorting: true
|
|
|
|
|
}),
|
|
|
|
|
columnHelper.accessor('title', {
|
|
|
|
|
id: 'title',
|
|
|
|
|
header: 'Название',
|
|
|
|
|
minSize: 200,
|
|
|
|
|
size: 800,
|
|
|
|
|
maxSize: 800,
|
|
|
|
|
enableSorting: true
|
|
|
|
|
}),
|
|
|
|
|
columnHelper.accessor('time_update', {
|
2023-12-25 16:53:27 +03:00
|
|
|
|
id: 'time_update',
|
2023-12-28 14:04:44 +03:00
|
|
|
|
header: 'Обновлена',
|
|
|
|
|
minSize: 150,
|
|
|
|
|
size: 150,
|
|
|
|
|
maxSize: 150,
|
|
|
|
|
cell: props => (
|
2024-01-04 15:04:14 +03:00
|
|
|
|
<div className='text-sm whitespace-nowrap'>{new Date(props.cell.getValue()).toLocaleString(intl.locale)}</div>
|
2023-12-28 14:04:44 +03:00
|
|
|
|
),
|
|
|
|
|
enableSorting: true
|
|
|
|
|
})
|
|
|
|
|
],
|
|
|
|
|
[intl]
|
|
|
|
|
);
|
2023-08-26 17:26:49 +03:00
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
|
return (
|
|
|
|
|
<motion.div
|
|
|
|
|
initial={{ ...animateSideView.initial }}
|
|
|
|
|
animate={{ ...animateSideView.animate }}
|
|
|
|
|
exit={{ ...animateSideView.exit }}
|
|
|
|
|
>
|
|
|
|
|
<h1 className='mb-6'>Отслеживаемые схемы</h1>
|
|
|
|
|
<DataTable
|
|
|
|
|
dense
|
|
|
|
|
noFooter
|
|
|
|
|
className='max-h-[23.8rem] overflow-y-auto text-sm border'
|
|
|
|
|
columns={columns}
|
|
|
|
|
data={items}
|
|
|
|
|
headPosition='0'
|
|
|
|
|
enableSorting
|
|
|
|
|
initialSorting={{
|
|
|
|
|
id: 'time_update',
|
|
|
|
|
desc: true
|
|
|
|
|
}}
|
|
|
|
|
noDataComponent={<div className='h-[10rem]'>Отслеживаемые схемы отсутствуют</div>}
|
|
|
|
|
onRowClicked={openRSForm}
|
|
|
|
|
/>
|
|
|
|
|
</motion.div>
|
|
|
|
|
);
|
2023-08-26 17:26:49 +03:00
|
|
|
|
}
|
|
|
|
|
|
2023-12-28 14:04:44 +03:00
|
|
|
|
export default ViewSubscriptions;
|