From 1a372fb0f8a7be5766267c80adf73abf589afa4e Mon Sep 17 00:00:00 2001 From: Anton Tananaev Date: Sun, 2 Oct 2022 09:32:45 -0700 Subject: Persist report form (fix #1019) --- modern/src/store/reports.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 modern/src/store/reports.js (limited to 'modern/src/store/reports.js') 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 }; -- cgit v1.2.3