Proyectos de Subversion LeadersLinked - SPA

Rev

Rev 2312 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 2312 Rev 3719
Línea 1... Línea 1...
1
import { QUIZ_ACTIONS } from './quiz.types'
1
import { QUIZ_ACTIONS } from './quiz.types';
2
 
2
 
3
const initialState = {
3
const initialState = {
4
  status: 'default',
4
  status: 'default',
5
  questions: [],
5
  questions: [],
6
  answers: [],
6
  answers: [],
7
  score: 0,
7
  score: 0,
8
  currentQuestion: 0,
8
  currentQuestion: 0,
9
  isFinished: false
9
  isFinished: false
10
}
10
};
11
 
11
 
12
const quizReducer = (state = initialState, { type, payload }) => {
12
const quizReducer = (state = initialState, { type, payload }) => {
13
  switch (type) {
13
  switch (type) {
14
    case QUIZ_ACTIONS.SET_QUESTIONS: {
14
    case QUIZ_ACTIONS.SET_QUESTIONS: {
15
      return { ...state, questions: payload }
15
      return { ...state, questions: payload };
16
    }
16
    }
17
    case QUIZ_ACTIONS.SET_STATUS: {
17
    case QUIZ_ACTIONS.SET_STATUS: {
18
      return { ...state, status: payload }
18
      return { ...state, status: payload };
19
    }
19
    }
20
    case QUIZ_ACTIONS.SET_ANSWER: {
20
    case QUIZ_ACTIONS.SET_ANSWER: {
21
      return { ...state, answers: [...state.answers, payload] }
21
      return { ...state, answers: [...state.answers, payload] };
22
    }
22
    }
23
    default:
23
    default:
24
      return state
24
      return state;
25
  }
25
  }
26
}
26
};
27
 
27
 
28
export default quizReducer
28
export default quizReducer;