2022-08-06 01:36:13 +03:00
|
|
|
import React, { FunctionComponent, useEffect, useRef } from 'react';
|
|
|
|
|
|
|
|
import IconButtonElement from '../../elements/IconButtonElement';
|
|
|
|
|
|
|
|
const NewCollection: FunctionComponent = () => {
|
|
|
|
const element = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const btnNewCollection = element.current?.querySelector('.btnNewCollection') as HTMLButtonElement;
|
|
|
|
if (btnNewCollection) {
|
|
|
|
btnNewCollection.addEventListener('click', () => {
|
2022-08-06 02:50:41 +03:00
|
|
|
import('../../components/collectionEditor/collectionEditor').then(({default: CollectionEditor}) => {
|
2022-08-06 01:36:13 +03:00
|
|
|
const serverId = window.ApiClient.serverId();
|
2022-08-06 02:50:41 +03:00
|
|
|
const collectionEditor = new CollectionEditor();
|
|
|
|
collectionEditor.show({
|
2022-08-06 01:36:13 +03:00
|
|
|
items: [],
|
|
|
|
serverId: serverId
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
return (
|
|
|
|
<div ref={element}>
|
|
|
|
<IconButtonElement
|
|
|
|
is='paper-icon-button-light'
|
|
|
|
className='btnNewCollection autoSize'
|
|
|
|
title='Add'
|
|
|
|
icon='material-icons add'
|
|
|
|
/>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
|
|
|
export default NewCollection;
|