import {TargetConstants} from 'constants/TargetConstants'

let defaultTargetState = {
	targetTypes : [],
	targetList : [],
	courseList : [],
	topicList : [],
	examList : []
}

export function targetReducer (state = defaultTargetState, action) {
	switch(action.type) {
		case TargetConstants.GET_TARGET_TYPES:
			return Object.assign(
				{},
				state,
				{
					targetTypes : action.targetTypes
				}
			)
		case TargetConstants.GET_TARGET_LIST:
			return Object.assign(
				{},
				state,
				{
					targetList : action.targets
				}
			)
		case TargetConstants.GET_COURSE_LIST:
			return Object.assign(
				{},
				state,
				{
					courseList : action.courseList
				}
			)
		case TargetConstants.GET_TOPIC_LIST:
			return Object.assign(
				{},
				state,
				{
					topicList : action.topicList
				}
			)
		case TargetConstants.GET_EXAM_LIST:
			return Object.assign(
				{},
				state,
				{
					examList : action.examList
				}
			)
		default:
			return state
	}
}