Skip to content

Instantly share code, notes, and snippets.

@emanueleDiVizio
Created June 1, 2020 17:18
Show Gist options
  • Select an option

  • Save emanueleDiVizio/d271963e55848a4df3b7be96dbfe518f to your computer and use it in GitHub Desktop.

Select an option

Save emanueleDiVizio/d271963e55848a4df3b7be96dbfe518f to your computer and use it in GitHub Desktop.
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