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