ConceptPortal-public/rsconcept/frontend/src/features/oss/dialogs/dlg-edit-operation/tab-operation.tsx
Ivan 9420729a96
Some checks failed
Frontend CI / build (22.x) (push) Has been cancelled
Frontend CI / notify-failure (push) Has been cancelled
R: Improve dialogs persistence when data is invalidated
2025-08-13 22:08:03 +03:00

60 lines
1.6 KiB
TypeScript

import { Controller, useFormContext } from 'react-hook-form';
import { TextArea, TextInput } from '@/components/input';
import { type IUpdateOperationDTO } from '../../backend/types';
import { SelectParent } from '../../components/select-parent';
import { type IOperationSchema } from '../../models/oss';
interface TabOperationProps {
oss: IOperationSchema;
}
export function TabOperation({ oss }: TabOperationProps) {
const {
register,
control,
formState: { errors }
} = useFormContext<IUpdateOperationDTO>();
return (
<div className='cc-fade-in cc-column'>
<TextInput
id='operation_title'
label='Название'
{...register('item_data.title')}
error={errors.item_data?.title}
/>
<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
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
rows={5}
{...register('item_data.description')}
error={errors.item_data?.description}
/>
</div>
);
}