Skip to content

State (Reducers)

Shawn DelPercio edited this page May 28, 2020 · 2 revisions

Reducers

Index.js

A file to import all reducers from authReducer.js, reviewReducer.js, companyReducer.js, and userReducer.js and merge them for the Redux store.

authReducer.js

Handles any state associated with authentication. Any action creators in authActions.js will be dispatched to this reducer.

initial state:

{
  isLoading: false,
  isLoggedIn: false,
  isSignedUp: false,
  isBlocked: false,
  isAdmin: false,
  error: null,
  status: null
}

reviewReducer.js

Handles any state associated with reviews. Any action creators in reviewActions.js will be dispatched to this reducer.

initial state:

{
  data: [],
  dataById: {},
  fetchingData: false,
  isLoading: false,
  isEditing: false,
  isDeleting: false,
  reviewAdded: false,
  reviewEdited: false,
  reviewDeleted: false,
  deleteFail: false,
  error: ""
}

companyReducer.js

Handles any state associated with companies. Any action creators in companyActions.js will be dispatched to this reducer.

initial state:

{
  data: [],
  dataById: {},
  fetchingData: false,
  isLoading: false,
  companyAdded: false,
  error: ''
}

userReducer.js

Handles any state associated with user information. Any action creators in userActions.js will be dispatched to this reducer.

initial state:

{
  userData: {},
  isLoading: false,
  isUpdated: false,
  isUserBlocked: null,
  error: ""
}