aboutsummaryrefslogtreecommitdiff
path: root/modern/src/store
diff options
context:
space:
mode:
authorAnton Tananaev <anton@traccar.org>2022-10-02 09:32:45 -0700
committerAnton Tananaev <anton@traccar.org>2022-10-02 09:32:45 -0700
commit1a372fb0f8a7be5766267c80adf73abf589afa4e (patch)
tree8855a5e3fe93b0fe1febb8cf94bd9c4f70bca9df /modern/src/store
parent9e581b0ede5d275ce8555f1324a4d0da56a256bf (diff)
downloadtrackermap-web-1a372fb0f8a7be5766267c80adf73abf589afa4e.tar.gz
trackermap-web-1a372fb0f8a7be5766267c80adf73abf589afa4e.tar.bz2
trackermap-web-1a372fb0f8a7be5766267c80adf73abf589afa4e.zip
Persist report form (fix #1019)
Diffstat (limited to 'modern/src/store')
-rw-r--r--modern/src/store/index.js3
-rw-r--r--modern/src/store/reports.js37
2 files changed, 40 insertions, 0 deletions
diff --git a/modern/src/store/index.js b/modern/src/store/index.js
index 9fce43cf..71c0b2b8 100644
--- a/modern/src/store/index.js
+++ b/modern/src/store/index.js
@@ -9,6 +9,7 @@ import { geofencesReducer as geofences } from './geofences';
import { groupsReducer as groups } from './groups';
import { driversReducer as drivers } from './drivers';
import { maintenancesReducer as maintenances } from './maintenances';
+import { reportsReducer as reports } from './reports';
import throttleMiddleware from './throttleMiddleware';
const reducer = combineReducers({
@@ -21,6 +22,7 @@ const reducer = combineReducers({
groups,
drivers,
maintenances,
+ reports,
});
export { errorsActions } from './errors';
@@ -32,6 +34,7 @@ export { geofencesActions } from './geofences';
export { groupsActions } from './groups';
export { driversActions } from './drivers';
export { maintenancesActions } from './maintenances';
+export { reportsActions } from './reports';
export default configureStore({
reducer,
diff --git a/modern/src/store/reports.js b/modern/src/store/reports.js
new file mode 100644
index 00000000..0c336f7a
--- /dev/null
+++ b/modern/src/store/reports.js
@@ -0,0 +1,37 @@
+import { createSlice } from '@reduxjs/toolkit';
+import moment from 'moment';
+
+const { reducer, actions } = createSlice({
+ name: 'reports',
+ initialState: {
+ deviceId: null,
+ deviceIds: [],
+ groupIds: [],
+ period: 'today',
+ from: moment().subtract(1, 'hour').locale('en').format(moment.HTML5_FMT.DATETIME_LOCAL),
+ to: moment().locale('en').format(moment.HTML5_FMT.DATETIME_LOCAL),
+ },
+ reducers: {
+ updateDeviceId(state, action) {
+ state.deviceId = action.payload;
+ },
+ updateDeviceIds(state, action) {
+ state.deviceIds = action.payload;
+ },
+ updateGroupIds(state, action) {
+ state.groupIds = action.payload;
+ },
+ updatePeriod(state, action) {
+ state.period = action.payload;
+ },
+ updateFrom(state, action) {
+ state.from = action.payload;
+ },
+ updateTo(state, action) {
+ state.to = action.payload;
+ },
+ },
+});
+
+export { actions as reportsActions };
+export { reducer as reportsReducer };