Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

scheduleAppointmentReducer.js 979B

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. import {
  2. SCHEDULE_APPOINTMENT_SUCCESS,
  3. SCHEDULE_APPOINTMENT_ERR,
  4. CLEAR_NOT_SENT_EMAILS_ARRAY,
  5. } from "../../actions/scheduleAppointment/scheduleAppointmentActionConstants";
  6. import createReducer from "../../utils/createReducer";
  7. /* istanbul ignore file */
  8. const initialState = {
  9. notSentEmails: null,
  10. errorMessage: "",
  11. };
  12. export default createReducer(
  13. {
  14. [SCHEDULE_APPOINTMENT_SUCCESS]: setStateScheduleAppointment,
  15. [SCHEDULE_APPOINTMENT_ERR]: setScheduleAppointmentErrorMessage,
  16. [CLEAR_NOT_SENT_EMAILS_ARRAY]: setNotSentEmailsArrayNull,
  17. },
  18. initialState
  19. );
  20. function setStateScheduleAppointment(state, action) {
  21. return {
  22. ...state,
  23. notSentEmails: action.payload ? [...action.payload.notSentEmails] : null,
  24. };
  25. }
  26. function setScheduleAppointmentErrorMessage(state, action) {
  27. return {
  28. ...state,
  29. errorMessage: action.payload,
  30. };
  31. }
  32. function setNotSentEmailsArrayNull(state) {
  33. return {
  34. ...state,
  35. notSentEmails: null,
  36. };
  37. }