2025-04-21 20:37:11 +03:00
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import { Controller, useFormContext } from 'react-hook-form';
|
|
|
|
|
|
|
|
|
|
import { TextArea, TextInput } from '@/components/input';
|
|
|
|
|
import { useDialogsStore } from '@/stores/dialogs';
|
|
|
|
|
|
|
|
|
|
import { type ICreateBlockDTO } 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 DlgCreateBlockProps } from './dlg-create-block';
|
|
|
|
|
|
|
|
|
|
export function TabBlockCard() {
|
|
|
|
|
const { oss } = useDialogsStore(state => state.props as DlgCreateBlockProps);
|
|
|
|
|
const {
|
|
|
|
|
register,
|
|
|
|
|
control,
|
|
|
|
|
formState: { errors }
|
|
|
|
|
} = useFormContext<ICreateBlockDTO>();
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div className='cc-fade-in cc-column'>
|
|
|
|
|
<TextInput
|
|
|
|
|
id='operation_title' //
|
|
|
|
|
label='Название'
|
|
|
|
|
{...register('item_data.title')}
|
|
|
|
|
error={errors.item_data?.title}
|
|
|
|
|
/>
|
|
|
|
|
<Controller
|
|
|
|
|
name='item_data.parent'
|
|
|
|
|
control={control}
|
|
|
|
|
render={({ field }) => (
|
2025-04-22 13:59:14 +03:00
|
|
|
<SelectParent
|
2025-04-21 20:37:11 +03:00
|
|
|
items={oss.blocks}
|
|
|
|
|
value={field.value ? oss.blockByID.get(field.value) ?? null : null}
|
|
|
|
|
placeholder='Блок содержания не выбран'
|
|
|
|
|
onChange={value => field.onChange(value ? value.id : null)}
|
|
|
|
|
/>
|
|
|
|
|
)}
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
|
|
<TextArea
|
|
|
|
|
id='operation_comment' //
|
|
|
|
|
label='Описание'
|
|
|
|
|
noResize
|
2025-04-22 13:59:14 +03:00
|
|
|
rows={5}
|
2025-04-21 20:37:11 +03:00
|
|
|
{...register('item_data.description')}
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|