Portal/rsconcept/frontend/src/features/oss/dialogs/dlg-create-operation/tab-synthesis-operation.tsx

60 lines
1.8 KiB
TypeScript
Raw Normal View History

2025-02-11 12:34:28 +03:00
import { Controller, useFormContext, useWatch } from 'react-hook-form';
2025-03-12 11:54:32 +03:00
import { Label, TextArea, TextInput } from '@/components/input1';
2025-02-12 00:14:18 +03:00
import { useDialogsStore } from '@/stores/dialogs';
2025-02-20 20:22:05 +03:00
import { type IOperationCreateDTO } from '../../backend/types';
2025-03-12 11:54:32 +03:00
import { PickMultiOperation } from '../../components/pick-multi-operation';
2025-02-12 21:36:03 +03:00
2025-03-12 11:54:32 +03:00
import { type DlgCreateOperationProps } from './dlg-create-operation';
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='Сокращение'
2025-03-10 16:01:40 +03:00
className='w-64'
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>
2025-03-07 22:04:56 +03:00
<div className='cc-column'>
2024-07-26 21:08:31 +03:00
<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} />
)}
/>
2025-03-07 22:04:56 +03:00
</div>
2024-12-12 13:17:24 +03:00
</div>
2024-07-21 15:17:36 +03:00
);
}