2024-08-15 23:23:10 +03:00
|
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import clsx from 'clsx';
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
|
2024-08-19 22:03:08 +03:00
|
|
|
|
import BadgeHelp from '@/components/info/BadgeHelp';
|
2024-08-15 23:23:10 +03:00
|
|
|
|
import Checkbox from '@/components/ui/Checkbox';
|
|
|
|
|
import Modal, { ModalProps } from '@/components/ui/Modal';
|
2024-08-19 22:03:08 +03:00
|
|
|
|
import Overlay from '@/components/ui/Overlay';
|
2024-08-15 23:23:10 +03:00
|
|
|
|
import TextInput from '@/components/ui/TextInput';
|
2024-08-19 22:03:08 +03:00
|
|
|
|
import { HelpTopic } from '@/models/miscellaneous';
|
2024-08-15 23:23:10 +03:00
|
|
|
|
import { IOperation } from '@/models/oss';
|
2024-08-19 22:03:08 +03:00
|
|
|
|
import { PARAMETER } from '@/utils/constants';
|
2024-08-15 23:23:10 +03:00
|
|
|
|
|
|
|
|
|
interface DlgDeleteOperationProps extends Pick<ModalProps, 'hideWindow'> {
|
|
|
|
|
target: IOperation;
|
|
|
|
|
onSubmit: (keepConstituents: boolean, deleteSchema: boolean) => void;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function DlgDeleteOperation({ hideWindow, target, onSubmit }: DlgDeleteOperationProps) {
|
|
|
|
|
const [keepConstituents, setKeepConstituents] = useState(false);
|
|
|
|
|
const [deleteSchema, setDeleteSchema] = useState(false);
|
|
|
|
|
|
|
|
|
|
function handleSubmit() {
|
|
|
|
|
onSubmit(keepConstituents, deleteSchema);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<Modal
|
|
|
|
|
overflowVisible
|
|
|
|
|
header='Удаление операции'
|
|
|
|
|
submitText='Подтвердить удаление'
|
|
|
|
|
hideWindow={hideWindow}
|
|
|
|
|
canSubmit={true}
|
|
|
|
|
onSubmit={handleSubmit}
|
|
|
|
|
className={clsx('w-[35rem]', 'pb-3 px-6 cc-column', 'select-none')}
|
|
|
|
|
>
|
2024-08-19 22:03:08 +03:00
|
|
|
|
<Overlay position='top-[-2rem] right-[4rem]'>
|
|
|
|
|
<BadgeHelp
|
|
|
|
|
topic={HelpTopic.CC_PROPAGATION}
|
|
|
|
|
className={clsx(PARAMETER.TOOLTIP_WIDTH, 'sm:max-w-[40rem]')}
|
|
|
|
|
offset={14}
|
|
|
|
|
/>
|
|
|
|
|
</Overlay>
|
|
|
|
|
|
2024-08-15 23:23:10 +03:00
|
|
|
|
<TextInput
|
|
|
|
|
disabled
|
|
|
|
|
dense
|
|
|
|
|
noBorder
|
|
|
|
|
id='operation_alias'
|
|
|
|
|
label='Операция'
|
|
|
|
|
className='w-full'
|
|
|
|
|
value={target.alias}
|
|
|
|
|
/>
|
|
|
|
|
<Checkbox
|
|
|
|
|
label='Сохранить наследованные конституенты'
|
|
|
|
|
titleHtml='Наследованные конституенты <br/>превратятся в дописанные'
|
|
|
|
|
value={keepConstituents}
|
|
|
|
|
setValue={setKeepConstituents}
|
2024-08-19 18:32:21 +03:00
|
|
|
|
disabled={target.result === null}
|
2024-08-15 23:23:10 +03:00
|
|
|
|
/>
|
|
|
|
|
<Checkbox
|
|
|
|
|
label='Удалить схему'
|
|
|
|
|
titleHtml={
|
|
|
|
|
!target.is_owned || target.result === undefined
|
|
|
|
|
? 'Привязанную схему нельзя удалить'
|
|
|
|
|
: 'Удалить схему вместе с операцией'
|
|
|
|
|
}
|
|
|
|
|
value={deleteSchema}
|
|
|
|
|
setValue={setDeleteSchema}
|
2024-08-19 18:32:21 +03:00
|
|
|
|
disabled={!target.is_owned || target.result === null}
|
2024-08-15 23:23:10 +03:00
|
|
|
|
/>
|
|
|
|
|
</Modal>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default DlgDeleteOperation;
|