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
|
|
|
|
2025-04-20 16:21:06 +03:00
|
|
|
import { type IUpdateOperationDTO } from '../../backend/types';
|
2025-04-21 20:37:11 +03:00
|
|
|
import { SelectBlock } from '../../components/select-block';
|
|
|
|
|
|
|
|
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-21 20:37:11 +03:00
|
|
|
const { oss } = 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 }
|
2025-04-20 16:21:06 +03:00
|
|
|
} = useFormContext<IUpdateOperationDTO>();
|
2024-07-29 16:56:24 +03:00
|
|
|
|
|
|
|
return (
|
2024-12-12 13:19:12 +03:00
|
|
|
<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
|
|
|
/>
|
|
|
|
<div className='flex gap-6'>
|
2025-04-21 20:37:11 +03:00
|
|
|
<div className='grid gap-1'>
|
|
|
|
<TextInput
|
|
|
|
id='operation_alias' //
|
|
|
|
label='Сокращение'
|
|
|
|
className='w-64'
|
|
|
|
{...register('item_data.alias')}
|
|
|
|
error={errors.item_data?.alias}
|
|
|
|
/>
|
|
|
|
<Controller
|
|
|
|
name='item_data.parent'
|
|
|
|
control={control}
|
|
|
|
render={({ field }) => (
|
|
|
|
<SelectBlock
|
|
|
|
items={oss.blocks}
|
|
|
|
value={field.value ? oss.blockByID.get(field.value) ?? null : null}
|
|
|
|
placeholder='Блок содержания'
|
|
|
|
onChange={value => field.onChange(value ? value.id : null)}
|
|
|
|
/>
|
|
|
|
)}
|
|
|
|
/>
|
|
|
|
</div>
|
2024-07-29 16:56:24 +03:00
|
|
|
<TextArea
|
|
|
|
id='operation_comment'
|
|
|
|
label='Описание'
|
|
|
|
noResize
|
|
|
|
rows={3}
|
2025-03-25 22:30:56 +03:00
|
|
|
{...register('item_data.description')}
|
|
|
|
error={errors.item_data?.description}
|
2024-07-29 16:56:24 +03:00
|
|
|
/>
|
|
|
|
</div>
|
2024-12-12 13:19:12 +03:00
|
|
|
</div>
|
2024-07-29 16:56:24 +03:00
|
|
|
);
|
|
|
|
}
|