ConceptPortal-public/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:35:14 +03:00
import { Controller, useFormContext, useWatch } from 'react-hook-form';
2025-03-12 12:04:50 +03:00
import { Label, TextArea, TextInput } from '@/components/input';
2025-02-12 00:14:38 +03:00
import { useDialogsStore } from '@/stores/dialogs';
import { type IOperationCreateDTO } from '../../backend/types';
2025-03-12 11:55:43 +03:00
import { PickMultiOperation } from '../../components/pick-multi-operation';
2025-02-12 21:36:25 +03:00
2025-03-12 11:55:43 +03:00
import { type DlgCreateOperationProps } from './dlg-create-operation';
2024-07-21 15:19:57 +03:00
2025-02-19 23:30:35 +03:00
export function TabSynthesisOperation() {
2025-02-12 00:14:38 +03:00
const { oss } = useDialogsStore(state => state.props as DlgCreateOperationProps);
2025-02-11 12:35:14 +03:00
const {
register,
control,
formState: { errors }
} = useFormContext<IOperationCreateDTO>();
const inputs = useWatch({ control, name: 'arguments' });
2024-07-21 15:19:57 +03:00
return (
<div className='cc-fade-in cc-column'>
2024-07-21 15:19:57 +03:00
<TextInput
id='operation_title'
label='Полное название'
2025-02-11 12:35:14 +03:00
{...register('item_data.title')}
error={errors.item_data?.title}
2024-07-21 15:19:57 +03:00
/>
<div className='flex gap-6'>
<TextInput
id='operation_alias'
label='Сокращение'
2025-03-10 16:02:53 +03:00
className='w-64'
2025-02-11 12:35:14 +03:00
{...register('item_data.alias')}
error={errors.item_data?.alias}
2024-07-21 15:19:57 +03:00
/>
<TextArea
id='operation_comment'
label='Описание'
noResize
rows={3}
{...register('item_data.description')}
error={errors.item_data?.description}
2024-07-21 15:19:57 +03:00
/>
</div>
2025-03-07 22:05:12 +03:00
<div className='cc-column'>
2024-07-26 21:09:16 +03:00
<Label text={`Выбор аргументов: [ ${inputs.length} ]`} />
2025-02-11 12:35:14 +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:05:12 +03:00
</div>
</div>
2024-07-21 15:19:57 +03:00
);
}