2025-02-11 12:34:28 +03:00
|
|
|
import { Controller, useFormContext, useWatch } from 'react-hook-form';
|
|
|
|
|
2025-02-10 01:32:16 +03:00
|
|
|
import { FlexColumn } from '@/components/Container';
|
|
|
|
import { Label, TextArea, TextInput } from '@/components/Input';
|
2025-02-12 00:14:18 +03:00
|
|
|
import { useDialogsStore } from '@/stores/dialogs';
|
2025-02-10 01:32:16 +03:00
|
|
|
|
2025-02-20 20:22:05 +03:00
|
|
|
import { type IOperationCreateDTO } from '../../backend/types';
|
2025-02-12 00:14:18 +03:00
|
|
|
import { PickMultiOperation } from '../../components/PickMultiOperation';
|
2025-02-12 21:36:03 +03:00
|
|
|
|
2025-02-20 20:22:05 +03:00
|
|
|
import { type DlgCreateOperationProps } from './DlgCreateOperation';
|
2024-07-21 15:17:36 +03:00
|
|
|
|
2025-02-19 23:29:45 +03:00
|
|
|
export function TabSynthesisOperation() {
|
2025-02-12 00:14:18 +03:00
|
|
|
const { oss } = useDialogsStore(state => state.props as DlgCreateOperationProps);
|
2025-02-11 12:34:28 +03:00
|
|
|
const {
|
|
|
|
register,
|
|
|
|
control,
|
|
|
|
formState: { errors }
|
|
|
|
} = useFormContext<IOperationCreateDTO>();
|
|
|
|
const inputs = useWatch({ control, name: 'arguments' });
|
|
|
|
|
2024-07-21 15:17:36 +03:00
|
|
|
return (
|
2024-12-12 13:17:24 +03:00
|
|
|
<div className='cc-fade-in cc-column'>
|
2024-07-21 15:17:36 +03:00
|
|
|
<TextInput
|
|
|
|
id='operation_title'
|
|
|
|
label='Полное название'
|
2025-02-11 12:34:28 +03:00
|
|
|
{...register('item_data.title')}
|
|
|
|
error={errors.item_data?.title}
|
2024-07-21 15:17:36 +03:00
|
|
|
/>
|
|
|
|
<div className='flex gap-6'>
|
|
|
|
<TextInput
|
|
|
|
id='operation_alias'
|
|
|
|
label='Сокращение'
|
2024-08-22 23:23:26 +03:00
|
|
|
className='w-[16rem]'
|
2025-02-11 12:34:28 +03:00
|
|
|
{...register('item_data.alias')}
|
|
|
|
error={errors.item_data?.alias}
|
2024-07-21 15:17:36 +03:00
|
|
|
/>
|
|
|
|
|
|
|
|
<TextArea
|
|
|
|
id='operation_comment'
|
|
|
|
label='Описание'
|
|
|
|
noResize
|
|
|
|
rows={3}
|
2025-02-11 12:34:28 +03:00
|
|
|
{...register('item_data.comment')}
|
|
|
|
error={errors.item_data?.comment}
|
2024-07-21 15:17:36 +03:00
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
|
2024-07-26 21:08:31 +03:00
|
|
|
<FlexColumn>
|
|
|
|
<Label text={`Выбор аргументов: [ ${inputs.length} ]`} />
|
2025-02-11 12:34:28 +03:00
|
|
|
<Controller
|
|
|
|
name='arguments'
|
|
|
|
control={control}
|
|
|
|
render={({ field }) => (
|
|
|
|
<PickMultiOperation items={oss.items} value={field.value} onChange={field.onChange} rows={6} />
|
|
|
|
)}
|
|
|
|
/>
|
2024-07-26 21:08:31 +03:00
|
|
|
</FlexColumn>
|
2024-12-12 13:17:24 +03:00
|
|
|
</div>
|
2024-07-21 15:17:36 +03:00
|
|
|
);
|
|
|
|
}
|