import { createSelector } from '@reduxjs/toolkit'; import { MinervaPlugin } from '@/types/models'; import { rootSelector } from '../root/root.selectors'; export const pluginsSelector = createSelector(rootSelector, state => state.plugins); export const activePluginsIdSelector = createSelector( pluginsSelector, state => state.activePlugins.pluginsId, ); export const pluginsDataSelector = createSelector( pluginsSelector, plugins => plugins.activePlugins.data, ); export const activePluginsSelector = createSelector( pluginsDataSelector, activePluginsIdSelector, (data, pluginsId) => { const result: MinervaPlugin[] = []; pluginsId.forEach(pluginId => { const element = data[pluginId]; if (element) { result.push(element); } }); return result; }, );