2024-03-01 18:19:33 +03:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
import clsx from 'clsx';
|
2024-12-13 21:31:09 +03:00
|
|
|
import { useState } from 'react';
|
2024-03-01 18:19:33 +03:00
|
|
|
|
2025-02-10 01:32:55 +03:00
|
|
|
import { ModalForm } from '@/components/Modal';
|
|
|
|
import { HelpTopic } from '@/features/help/models/helpTopic';
|
|
|
|
import { ICstSubstitute, ICstSubstitutions } from '@/features/oss/models/oss';
|
|
|
|
import PickSubstitutions from '@/features/rsform/components/PickSubstitutions';
|
2025-01-16 16:31:32 +03:00
|
|
|
import { useDialogsStore } from '@/stores/dialogs';
|
2024-03-01 18:19:33 +03:00
|
|
|
|
2025-02-10 01:32:55 +03:00
|
|
|
import { IRSForm } from '../models/rsform';
|
|
|
|
|
2025-01-16 16:31:32 +03:00
|
|
|
export interface DlgSubstituteCstProps {
|
2024-07-30 16:00:09 +03:00
|
|
|
schema: IRSForm;
|
2025-01-27 15:03:48 +03:00
|
|
|
onSubstitute: (data: ICstSubstitutions) => void;
|
2024-03-01 18:19:33 +03:00
|
|
|
}
|
|
|
|
|
2025-01-16 16:31:32 +03:00
|
|
|
function DlgSubstituteCst() {
|
|
|
|
const { onSubstitute, schema } = useDialogsStore(state => state.props as DlgSubstituteCstProps);
|
2024-07-30 16:00:09 +03:00
|
|
|
const [substitutions, setSubstitutions] = useState<ICstSubstitute[]>([]);
|
2024-12-13 21:31:09 +03:00
|
|
|
const canSubmit = substitutions.length > 0;
|
2024-03-01 18:19:33 +03:00
|
|
|
|
|
|
|
function handleSubmit() {
|
2025-02-06 14:10:18 +03:00
|
|
|
onSubstitute({ substitutions: substitutions });
|
|
|
|
return true;
|
2024-03-01 18:19:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
2025-02-06 20:28:23 +03:00
|
|
|
<ModalForm
|
2024-03-27 22:54:24 +03:00
|
|
|
header='Отождествление'
|
2024-03-01 18:19:33 +03:00
|
|
|
submitText='Отождествить'
|
2024-08-23 22:53:53 +03:00
|
|
|
submitInvalidTooltip='Выберите две различные конституенты'
|
2024-03-01 18:19:33 +03:00
|
|
|
canSubmit={canSubmit}
|
|
|
|
onSubmit={handleSubmit}
|
2024-03-27 22:54:24 +03:00
|
|
|
className={clsx('w-[40rem]', 'px-6 pb-3')}
|
2024-10-29 12:06:43 +03:00
|
|
|
helpTopic={HelpTopic.UI_SUBSTITUTIONS}
|
2024-03-01 18:19:33 +03:00
|
|
|
>
|
2024-07-30 16:00:09 +03:00
|
|
|
<PickSubstitutions
|
|
|
|
allowSelfSubstitution
|
2025-02-04 20:35:55 +03:00
|
|
|
value={substitutions}
|
|
|
|
onChange={setSubstitutions}
|
2024-03-27 22:54:24 +03:00
|
|
|
rows={6}
|
2024-07-30 16:00:09 +03:00
|
|
|
schemas={[schema]}
|
2024-03-01 18:19:33 +03:00
|
|
|
/>
|
2025-02-06 20:28:23 +03:00
|
|
|
</ModalForm>
|
2024-03-01 18:19:33 +03:00
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default DlgSubstituteCst;
|