mirror of
https://github.com/openmhz/trunk-server.git
synced 2026-11-13 09:17:30 -05:00
Systems sorted by State!
This commit is contained in:
26
frontend/src/features/systems/systemsSlice.js
Normal file
26
frontend/src/features/systems/systemsSlice.js
Normal file
@@ -0,0 +1,26 @@
|
||||
|
||||
import {
|
||||
createSlice,
|
||||
createEntityAdapter,
|
||||
createSelector
|
||||
} from '@reduxjs/toolkit'
|
||||
import { apiSlice} from '../api/apiSlice'
|
||||
|
||||
// Calling `someEndpoint.select(someArg)` generates a new selector that will return
|
||||
// the query result object for a query with those parameters.
|
||||
// To generate a selector for a specific query argument, call `select(theQueryArg)`.
|
||||
// In this case, the users query has no params, so we don't pass anything to select()
|
||||
export const selectSystemsResult = apiSlice.endpoints.getSystems.select()
|
||||
|
||||
const emptySystems = []
|
||||
|
||||
export const selectAllSystems = createSelector(
|
||||
selectSystemsResult,
|
||||
systemsResult => systemsResult.data?systemsResult.data.systems:emptySystems
|
||||
)
|
||||
|
||||
export const selectActiveSystems = createSelector(
|
||||
selectAllSystems,
|
||||
(state) => null,
|
||||
(systems) => systems.filter(system => system.active === true)
|
||||
)
|
||||
Reference in New Issue
Block a user