2024-03-18 16:22:27 +03:00
|
|
|
|
'use client';
|
|
|
|
|
|
|
2025-01-27 15:03:48 +03:00
|
|
|
|
import { useLibrary } from '@/backend/library/useLibrary';
|
2024-05-16 22:39:28 +03:00
|
|
|
|
import PickSchema from '@/components/select/PickSchema';
|
2024-03-18 16:22:27 +03:00
|
|
|
|
import TextInput from '@/components/ui/TextInput';
|
2024-08-17 22:31:24 +03:00
|
|
|
|
import { LibraryItemID, LibraryItemType } from '@/models/library';
|
2024-09-12 13:27:20 +03:00
|
|
|
|
import { IRSForm } from '@/models/rsform';
|
|
|
|
|
|
import { sortItemsForInlineSynthesis } from '@/models/rsformAPI';
|
2024-03-18 16:22:27 +03:00
|
|
|
|
|
2025-01-29 16:18:41 +03:00
|
|
|
|
interface TabSourceProps {
|
2024-03-18 16:22:27 +03:00
|
|
|
|
selected?: LibraryItemID;
|
2024-03-21 17:48:42 +03:00
|
|
|
|
setSelected: (newValue: LibraryItemID) => void;
|
2024-09-12 13:27:20 +03:00
|
|
|
|
receiver: IRSForm;
|
2024-03-18 16:22:27 +03:00
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-29 16:18:41 +03:00
|
|
|
|
function TabSource({ selected, receiver, setSelected }: TabSourceProps) {
|
2025-01-27 15:03:48 +03:00
|
|
|
|
const { items: libraryItems } = useLibrary();
|
|
|
|
|
|
const selectedInfo = libraryItems.find(item => item.id === selected);
|
|
|
|
|
|
const sortedItems = sortItemsForInlineSynthesis(receiver, libraryItems);
|
2024-03-18 16:22:27 +03:00
|
|
|
|
return (
|
2024-12-12 13:19:12 +03:00
|
|
|
|
<div className='cc-fade-in flex flex-col'>
|
2024-09-15 13:21:25 +03:00
|
|
|
|
<PickSchema
|
2025-01-27 15:03:48 +03:00
|
|
|
|
id='dlg_schema_picker' //
|
2024-09-15 13:21:25 +03:00
|
|
|
|
items={sortedItems}
|
|
|
|
|
|
itemType={LibraryItemType.RSFORM}
|
|
|
|
|
|
rows={14}
|
|
|
|
|
|
value={selected}
|
|
|
|
|
|
onSelectValue={setSelected}
|
|
|
|
|
|
/>
|
|
|
|
|
|
<div className='flex items-center gap-6 '>
|
2024-03-20 15:03:53 +03:00
|
|
|
|
<span className='select-none'>Выбрана</span>
|
|
|
|
|
|
<TextInput
|
|
|
|
|
|
id='dlg_selected_schema_title'
|
|
|
|
|
|
disabled
|
|
|
|
|
|
noBorder
|
2024-09-21 20:04:07 +03:00
|
|
|
|
className='flex-grow'
|
|
|
|
|
|
placeholder='Схема не выбрана'
|
2024-03-20 15:03:53 +03:00
|
|
|
|
value={selectedInfo?.title ?? ''}
|
|
|
|
|
|
dense
|
|
|
|
|
|
/>
|
|
|
|
|
|
</div>
|
2024-12-12 13:19:12 +03:00
|
|
|
|
</div>
|
2024-03-18 16:22:27 +03:00
|
|
|
|
);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-01-29 16:18:41 +03:00
|
|
|
|
export default TabSource;
|