aboutsummaryrefslogtreecommitdiff
path: root/modern/src/store
diff options
context:
space:
mode:
Diffstat (limited to 'modern/src/store')
-rw-r--r--modern/src/store/events.js22
-rw-r--r--modern/src/store/index.js3
2 files changed, 25 insertions, 0 deletions
diff --git a/modern/src/store/events.js b/modern/src/store/events.js
new file mode 100644
index 00000000..d4f313c0
--- /dev/null
+++ b/modern/src/store/events.js
@@ -0,0 +1,22 @@
+import { createSlice } from '@reduxjs/toolkit';
+
+const { reducer, actions } = createSlice({
+ name: 'events',
+ initialState: {
+ items: [],
+ },
+ reducers: {
+ add(state, action) {
+ state.items.unshift(...action.payload);
+ },
+ delete(state, action) {
+ state.items = state.items.filter((item) => item.id !== action.payload.id);
+ },
+ deleteAll(state) {
+ state.items = [];
+ },
+ },
+});
+
+export { actions as eventsActions };
+export { reducer as eventsReducer };
diff --git a/modern/src/store/index.js b/modern/src/store/index.js
index 2ab0c982..9fce43cf 100644
--- a/modern/src/store/index.js
+++ b/modern/src/store/index.js
@@ -4,6 +4,7 @@ import { errorsReducer as errors } from './errors';
import { sessionReducer as session } from './session';
import { devicesReducer as devices } from './devices';
import { positionsReducer as positions } from './positions';
+import { eventsReducer as events } from './events';
import { geofencesReducer as geofences } from './geofences';
import { groupsReducer as groups } from './groups';
import { driversReducer as drivers } from './drivers';
@@ -15,6 +16,7 @@ const reducer = combineReducers({
session,
devices,
positions,
+ events,
geofences,
groups,
drivers,
@@ -25,6 +27,7 @@ export { errorsActions } from './errors';
export { sessionActions } from './session';
export { devicesActions } from './devices';
export { positionsActions } from './positions';
+export { eventsActions } from './events';
export { geofencesActions } from './geofences';
export { groupsActions } from './groups';
export { driversActions } from './drivers';