2024-06-07 20:17:03 +03:00
|
|
|
|
'use client';
|
|
|
|
|
|
|
|
|
|
import PickSchema from '@/components/select/PickSchema';
|
|
|
|
|
import TextInput from '@/components/ui/TextInput';
|
|
|
|
|
import { useLibrary } from '@/context/LibraryContext';
|
2024-08-17 22:30:49 +03:00
|
|
|
|
import { LibraryItemID, LibraryItemType } from '@/models/library';
|
2024-09-12 13:27:06 +03:00
|
|
|
|
import { IRSForm } from '@/models/rsform';
|
|
|
|
|
import { sortItemsForInlineSynthesis } from '@/models/rsformAPI';
|
2024-06-07 20:17:03 +03:00
|
|
|
|
|
2024-06-26 19:47:05 +03:00
|
|
|
|
interface TabSchemaProps {
|
2024-06-07 20:17:03 +03:00
|
|
|
|
selected?: LibraryItemID;
|
|
|
|
|
setSelected: (newValue: LibraryItemID) => void;
|
2024-09-12 13:27:06 +03:00
|
|
|
|
receiver: IRSForm;
|
2024-06-07 20:17:03 +03:00
|
|
|
|
}
|
|
|
|
|
|
2024-09-12 13:27:06 +03:00
|
|
|
|
function TabSchema({ selected, receiver, setSelected }: TabSchemaProps) {
|
2024-06-07 20:17:03 +03:00
|
|
|
|
const library = useLibrary();
|
2024-12-13 21:30:49 +03:00
|
|
|
|
const selectedInfo = library.items.find(item => item.id === selected);
|
|
|
|
|
const sortedItems = sortItemsForInlineSynthesis(receiver, library.items);
|
2024-06-07 20:17:03 +03:00
|
|
|
|
|
|
|
|
|
return (
|
2024-12-12 13:17:24 +03:00
|
|
|
|
<div className='cc-fade-in flex flex-col'>
|
2024-09-15 13:20:25 +03:00
|
|
|
|
<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 '>
|
2024-06-07 20:17:03 +03:00
|
|
|
|
<span className='select-none'>Выбрана</span>
|
|
|
|
|
<TextInput
|
|
|
|
|
id='dlg_selected_schema_title'
|
|
|
|
|
disabled
|
|
|
|
|
noBorder
|
2024-09-21 20:03:49 +03:00
|
|
|
|
className='flex-grow'
|
|
|
|
|
placeholder='Схема не выбрана'
|
2024-06-07 20:17:03 +03:00
|
|
|
|
value={selectedInfo?.title ?? ''}
|
|
|
|
|
dense
|
|
|
|
|
/>
|
|
|
|
|
</div>
|
2024-12-12 13:17:24 +03:00
|
|
|
|
</div>
|
2024-06-07 20:17:03 +03:00
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2024-06-26 19:47:05 +03:00
|
|
|
|
export default TabSchema;
|