ConceptPortal-public/rsconcept/frontend/src/features/oss/dialogs/dlg-edit-operation/tab-operation.tsx

59 lines
1.6 KiB
TypeScript
Raw Normal View History

2025-04-21 20:37:11 +03:00
import { Controller, useFormContext } from 'react-hook-form';
2025-02-12 00:14:38 +03:00
2025-03-12 12:04:50 +03:00
import { TextArea, TextInput } from '@/components/input';
2025-04-21 20:37:11 +03:00
import { useDialogsStore } from '@/stores/dialogs';
2024-07-29 16:56:24 +03:00
import { type IUpdateOperationDTO } from '../../backend/types';
2025-04-22 13:59:14 +03:00
import { SelectParent } from '../../components/select-parent';
2025-04-21 20:37:11 +03:00
import { type DlgEditOperationProps } from './dlg-edit-operation';
2025-02-12 00:14:38 +03:00
2025-02-19 23:30:35 +03:00
export function TabOperation() {
2025-04-28 13:59:38 +03:00
const { manager } = useDialogsStore(state => state.props as DlgEditOperationProps);
2025-02-12 00:14:38 +03:00
const {
register,
2025-04-21 20:37:11 +03:00
control,
2025-02-12 00:14:38 +03:00
formState: { errors }
} = useFormContext<IUpdateOperationDTO>();
2024-07-29 16:56:24 +03:00
return (
<div className='cc-fade-in cc-column'>
2024-07-29 16:56:24 +03:00
<TextInput
id='operation_title'
2025-04-21 20:37:11 +03:00
label='Название'
2025-02-12 00:14:38 +03:00
{...register('item_data.title')}
error={errors.item_data?.title}
2024-07-29 16:56:24 +03:00
/>
2025-04-22 13:59:14 +03:00
<TextInput
id='operation_alias' //
label='Сокращение'
className='w-80'
{...register('item_data.alias')}
error={errors.item_data?.alias}
/>
<Controller
name='item_data.parent'
control={control}
render={({ field }) => (
<SelectParent
2025-04-28 13:59:38 +03:00
items={manager.oss.blocks}
value={field.value ? manager.oss.blockByID.get(field.value) ?? null : null}
2025-07-03 14:36:15 +03:00
placeholder='Родительский блок'
2025-04-22 13:59:14 +03:00
onChange={value => field.onChange(value ? value.id : null)}
2025-04-21 20:37:11 +03:00
/>
2025-04-22 13:59:14 +03:00
)}
/>
<TextArea
id='operation_comment'
label='Описание'
noResize
rows={5}
{...register('item_data.description')}
error={errors.item_data?.description}
/>
</div>
2024-07-29 16:56:24 +03:00
);
}