2024-06-07 20:17:03 +03:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
import clsx from 'clsx';
|
2024-12-13 21:30:49 +03:00
|
|
|
import { useState } from 'react';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
2024-07-30 15:59:37 +03:00
|
|
|
import PickSubstitutions from '@/components/select/PickSubstitutions';
|
2025-01-16 16:31:03 +03:00
|
|
|
import Modal from '@/components/ui/Modal';
|
2024-10-29 12:05:23 +03:00
|
|
|
import { HelpTopic } from '@/models/miscellaneous';
|
2025-01-23 19:41:31 +03:00
|
|
|
import { ICstSubstitute, ICstSubstitutions } from '@/models/oss';
|
2024-07-30 15:59:37 +03:00
|
|
|
import { IRSForm } from '@/models/rsform';
|
2025-01-16 16:31:03 +03:00
|
|
|
import { useDialogsStore } from '@/stores/dialogs';
|
2024-06-07 20:17:03 +03:00
|
|
|
import { prefixes } from '@/utils/constants';
|
|
|
|
|
2025-01-16 16:31:03 +03:00
|
|
|
export interface DlgSubstituteCstProps {
|
2024-07-30 15:59:37 +03:00
|
|
|
schema: IRSForm;
|
2025-01-23 19:41:31 +03:00
|
|
|
onSubstitute: (data: ICstSubstitutions) => void;
|
2024-06-07 20:17:03 +03:00
|
|
|
}
|
|
|
|
|
2025-01-16 16:31:03 +03:00
|
|
|
function DlgSubstituteCst() {
|
|
|
|
const { onSubstitute, schema } = useDialogsStore(state => state.props as DlgSubstituteCstProps);
|
2024-07-30 15:59:37 +03:00
|
|
|
const [substitutions, setSubstitutions] = useState<ICstSubstitute[]>([]);
|
2024-12-13 21:30:49 +03:00
|
|
|
const canSubmit = substitutions.length > 0;
|
2024-06-07 20:17:03 +03:00
|
|
|
|
|
|
|
function handleSubmit() {
|
2025-01-23 19:41:31 +03:00
|
|
|
const data: ICstSubstitutions = {
|
2024-07-30 15:59:37 +03:00
|
|
|
substitutions: substitutions
|
2024-06-07 20:17:03 +03:00
|
|
|
};
|
|
|
|
onSubstitute(data);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
<Modal
|
|
|
|
header='Отождествление'
|
|
|
|
submitText='Отождествить'
|
2024-08-23 22:53:32 +03:00
|
|
|
submitInvalidTooltip='Выберите две различные конституенты'
|
2024-06-07 20:17:03 +03:00
|
|
|
canSubmit={canSubmit}
|
|
|
|
onSubmit={handleSubmit}
|
|
|
|
className={clsx('w-[40rem]', 'px-6 pb-3')}
|
2024-10-29 12:05:23 +03:00
|
|
|
helpTopic={HelpTopic.UI_SUBSTITUTIONS}
|
2024-06-07 20:17:03 +03:00
|
|
|
>
|
2024-07-30 15:59:37 +03:00
|
|
|
<PickSubstitutions
|
|
|
|
allowSelfSubstitution
|
|
|
|
substitutions={substitutions}
|
|
|
|
setSubstitutions={setSubstitutions}
|
2024-06-07 20:17:03 +03:00
|
|
|
rows={6}
|
|
|
|
prefixID={prefixes.dlg_cst_substitutes_list}
|
2024-07-30 15:59:37 +03:00
|
|
|
schemas={[schema]}
|
2024-06-07 20:17:03 +03:00
|
|
|
/>
|
|
|
|
</Modal>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DlgSubstituteCst;
|