Portal/rsconcept/frontend/src/dialogs/DlgInlineSynthesis/TabSchema.tsx

48 lines
1.4 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

'use client';
import PickSchema from '@/components/select/PickSchema';
import TextInput from '@/components/ui/TextInput';
import { useLibrary } from '@/context/LibraryContext';
import { LibraryItemID, LibraryItemType } from '@/models/library';
import { IRSForm } from '@/models/rsform';
import { sortItemsForInlineSynthesis } from '@/models/rsformAPI';
interface TabSchemaProps {
selected?: LibraryItemID;
setSelected: (newValue: LibraryItemID) => void;
receiver: IRSForm;
}
function TabSchema({ selected, receiver, setSelected }: TabSchemaProps) {
const library = useLibrary();
const selectedInfo = library.items.find(item => item.id === selected);
const sortedItems = sortItemsForInlineSynthesis(receiver, library.items);
return (
<div className='cc-fade-in flex flex-col'>
<PickSchema
id='dlg_schema_picker' // prettier: split lines
items={sortedItems}
itemType={LibraryItemType.RSFORM}
rows={14}
value={selected}
onSelectValue={setSelected}
/>
<div className='flex items-center gap-6 '>
<span className='select-none'>Выбрана</span>
<TextInput
id='dlg_selected_schema_title'
disabled
noBorder
className='flex-grow'
placeholder='Схема не выбрана'
value={selectedInfo?.title ?? ''}
dense
/>
</div>
</div>
);
}
export default TabSchema;