'use client'; import { useCallback, useLayoutEffect, useMemo } from 'react'; import BadgeConstituenta from '@/components/info/BadgeConstituenta'; import DataTable, { createColumnHelper, IConditionalStyle } from '@/components/ui/DataTable'; import NoData from '@/components/ui/NoData'; import TextContent from '@/components/ui/TextContent'; import { useConceptOptions } from '@/context/ConceptOptionsContext'; import { ConstituentaID, IConstituenta } from '@/models/rsform'; import { isMockCst } from '@/models/rsformAPI'; import { PARAMETER, prefixes } from '@/utils/constants'; import { describeConstituenta } from '@/utils/labels'; const DESCRIPTION_MAX_SYMBOLS = 280; interface TableSideConstituentsProps { items: IConstituenta[]; activeCst?: IConstituenta; onOpenEdit: (cstID: ConstituentaID) => void; autoScroll?: boolean; maxHeight: string; } const columnHelper = createColumnHelper(); function TableSideConstituents({ items, activeCst, autoScroll = true, onOpenEdit, maxHeight }: TableSideConstituentsProps) { const { colors } = useConceptOptions(); useLayoutEffect(() => { if (!activeCst) { return; } if (autoScroll) { setTimeout(() => { const element = document.getElementById(`${prefixes.cst_side_table}${activeCst.alias}`); if (element) { element.scrollIntoView({ behavior: 'smooth', block: 'center', inline: 'end' }); } }, PARAMETER.refreshTimeout); } }, [activeCst, autoScroll]); const handleRowClicked = useCallback( (cst: IConstituenta) => { if (!isMockCst(cst)) { onOpenEdit(cst.id); } }, [onOpenEdit] ); const columns = useMemo( () => [ columnHelper.accessor('alias', { id: 'alias', header: () => Имя, size: 65, minSize: 65, footer: undefined, cell: props => ( ) }), columnHelper.accessor(cst => describeConstituenta(cst), { id: 'description', header: 'Описание', size: 1000, minSize: 250, maxSize: 1000, cell: props => ( ) }) ], [colors] ); const conditionalRowStyles = useMemo( (): IConditionalStyle[] => [ { when: (cst: IConstituenta) => !!activeCst && cst.id === activeCst?.id, style: { backgroundColor: colors.bgSelected } }, { when: (cst: IConstituenta) => !!activeCst && cst.spawner === activeCst?.id && cst.id !== activeCst?.id, style: { backgroundColor: colors.bgOrange50 } }, { when: (cst: IConstituenta) => activeCst?.id !== undefined && cst.spawn.includes(activeCst.id), style: { backgroundColor: colors.bgGreen50 } } ], [activeCst, colors] ); return (

Список конституент пуст

Измените параметры фильтра

} onRowClicked={handleRowClicked} /> ); } export default TableSideConstituents;