// Copyright (C) 2017-2020 Smart code 203358507

const React = require('react');

const useMetaExtensionTabs = (metaExtensions) => {
    const tabs = React.useMemo(() => {
        return metaExtensions
            .map((extension) => ({
                id: extension.url,
                label: extension.addon.manifest.name,
                logo: extension.addon.manifest.logo,
                icon: 'ic_addons',
                onClick: () => setSelected(extension)
            }));
    }, [metaExtensions]);
    const [selected, setSelected] = React.useState(null);
    const clear = React.useCallback(() => {
        setSelected(null);
    }, []);
    return [tabs, selected, clear];
};

module.exports = useMetaExtensionTabs;
