Created
June 1, 2020 17:18
-
-
Save emanueleDiVizio/d271963e55848a4df3b7be96dbfe518f to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const shiftSlice = createSlice({ | |
| name: 'shifts', | |
| initialState: [], | |
| reducers: { | |
| startShift: state => [ | |
| ...state, | |
| { | |
| startTime: moment().valueOf(), | |
| endTime: moment() | |
| .add(DEFAULT_SHIFT_DURATION, 'h') | |
| .valueOf(), | |
| }, | |
| ], | |
| endShift: state => { | |
| var newState = [...state] | |
| return [{ ...newState.pop(), endTime: moment().valueOf() }, ...newState] | |
| }, | |
| }, | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment