import { useMemo, useState } from 'react'; import Checkbox from '../components/common/Checkbox'; import Modal, { ModalProps } from '../components/common/Modal'; import { useRSForm } from '../context/RSFormContext'; import { prefixes } from '../utils/constants'; import { labelConstituenta } from '../utils/labels'; interface DlgDeleteCstProps extends Pick { selected: number[] onDelete: (items: number[]) => void } function DlgDeleteCst({ hideWindow, selected, onDelete }: DlgDeleteCstProps) { const { schema } = useRSForm(); const [ expandOut, setExpandOut ] = useState(false); const expansion: number[] = useMemo(() => schema?.graph.expandOutputs(selected) ?? [], [selected, schema?.graph]); function handleSubmit() { hideWindow(); if (expandOut) { onDelete(selected.concat(expansion)); } else { onDelete(selected); } } return (

Выбраны к удалению: {selected.length}

{selected.map( (id) => { const cst = schema!.items.find(cst => cst.id === id); return (cst ?

{labelConstituenta(cst)}

: null); })}

Зависимые конституенты: {expansion.length}

{expansion.map( (id) => { const cst = schema!.items.find(cst => cst.id === id); return (cst ?

{labelConstituenta(cst)}

: null); })}
setExpandOut(value)} />
); } export default DlgDeleteCst;