aboutsummaryrefslogtreecommitdiff
path: root/modern/src/store/errors.js
blob: d1b86e5a94810779dfc5e6f51e065e78a8b44788 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { createSlice } from '@reduxjs/toolkit';

const { reducer, actions } = createSlice({
  name: 'errors',
  initialState: {
    errors: [],
  },
  reducers: {
    push(state, action) {
      state.errors.push(action.payload);
    },
    pop(state, _) {
      if (state.errors.length) {
        state.errors.shift();
      }
    },
  },
});

export { actions as errorsActions };
export { reducer as errorsReducer };