const business = (state = {}, action) => {
    switch (action.type) {
        case 'PATROL_INIT_GRADE_BY_COMPLETED_DATE':
            {
                const completedDate = state.completedDate || []
                const { date } = action
                const record = completedDate.find(p => p.id === date.id)
                if (record) {
                    record.value = date.value
                } else {
                    completedDate.push(date)
                }
                const _state = { ...state, completedDate }
                return _state
            }
        case 'PATROL_REMOVE_INIT_GRADE_BY_COMPLETED_DATE':
            {
                const completedDate = state.completedDate || []
                const record = completedDate.find(p => p.id === action.id)
                if (!record) {
                    return state
                } else {
                    completedDate.splice(completedDate.indexOf(record), 1)
                    const _state = { ...state, completedDate }
                    return _state
                }
            }
        default:
            return state
    }
}

export default business