newTopic.js 909 B

12345678910111213141516171819202122232425262728293031323334
  1. import * as actionTypes from '../../../constants/admin';
  2. import initialState from '../../initialState';
  3. export default function newTopic(state = initialState.newTopic, {payload, type, error}) {
  4. switch (type) { // payload.type -> type
  5. case actionTypes.CHANGE_TEST_REQUEST: {
  6. return {
  7. ...state,
  8. isFetching: false,
  9. // payload
  10. }
  11. }
  12. case actionTypes.CHANGE_TOPIC_REQUEST_SUCCESS: {
  13. const {data:{topic}}=payload
  14. return {
  15. ...state,
  16. isFetching: true,
  17. data:topic
  18. }
  19. }
  20. // case actionTypes.CREATE_TOPICS_REQUEST_FAILURE: {
  21. // return {
  22. // ...state,
  23. // isFetching: false,
  24. // error
  25. // }
  26. // }
  27. default: {
  28. return state;
  29. }
  30. }
  31. }