-
Notifications
You must be signed in to change notification settings - Fork 50
/
Copy pathstatus.ts
32 lines (27 loc) · 1012 Bytes
/
status.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
import { createSlice } from '@reduxjs/toolkit';
import { fetchSystemStatus } from 'app/actions/StatusActions';
import { EntityType } from 'app/store/models/entities';
import createLegoAdapter from 'app/utils/legoAdapter/createLegoAdapter';
import type { SystemStatus } from 'app/actions/StatusActions';
import type { RootState } from 'app/store/createRootReducer';
type ExtraStatusState = {
systemStatus: SystemStatus | null;
};
const legoAdapter = createLegoAdapter(EntityType.SystemStatus);
const statusSlice = createSlice({
name: EntityType.SystemStatus,
initialState: legoAdapter.getInitialState({
systemStatus: null,
} as ExtraStatusState),
reducers: {},
extraReducers: legoAdapter.buildReducers({
extraCases: (addCase) => {
addCase(fetchSystemStatus.fulfilled, (state, action) => {
state.systemStatus = action.payload;
});
},
}),
});
export default statusSlice.reducer;
export const selectSystemStatus = (state: RootState) =>
state.status.systemStatus;