Portal/rsconcept/frontend/src/dialogs/DlgDeleteOperation.tsx
2025-02-06 20:27:56 +03:00

62 lines
2.2 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client';
import clsx from 'clsx';
import { useState } from 'react';
import Checkbox from '@/components/ui/Checkbox';
import { ModalForm } from '@/components/ui/Modal';
import TextInput from '@/components/ui/TextInput';
import { HelpTopic } from '@/models/miscellaneous';
import { IOperation, OperationID } from '@/models/oss';
import { useDialogsStore } from '@/stores/dialogs';
export interface DlgDeleteOperationProps {
target: IOperation;
onSubmit: (targetID: OperationID, keepConstituents: boolean, deleteSchema: boolean) => void;
}
function DlgDeleteOperation() {
const { target, onSubmit } = useDialogsStore(state => state.props as DlgDeleteOperationProps);
const [keepConstituents, setKeepConstituents] = useState(false);
const [deleteSchema, setDeleteSchema] = useState(false);
function handleSubmit() {
onSubmit(target.id, keepConstituents, deleteSchema);
return true;
}
return (
<ModalForm
overflowVisible
header='Удаление операции'
submitText='Подтвердить удаление'
canSubmit={true}
onSubmit={handleSubmit}
className={clsx('w-[35rem]', 'pb-3 px-6 cc-column', 'select-none')}
helpTopic={HelpTopic.CC_PROPAGATION}
>
<TextInput disabled dense noBorder id='operation_alias' label='Операция' value={target.alias} />
<Checkbox
label='Сохранить наследованные конституенты'
titleHtml='Наследованные конституенты <br/>превратятся в дописанные'
value={keepConstituents}
onChange={setKeepConstituents}
disabled={target.result === null}
/>
<Checkbox
label='Удалить схему'
titleHtml={
!target.is_owned || target.result === undefined
? 'Привязанную схему нельзя удалить'
: 'Удалить схему вместе с операцией'
}
value={deleteSchema}
onChange={setDeleteSchema}
disabled={!target.is_owned || target.result === null}
/>
</ModalForm>
);
}
export default DlgDeleteOperation;