import {COOKIE_SHOW, COOKIE_HIDE,ADD_INTERVIEWEE,REMOVE_INTERVIEWEE, CLEAR_INTERVIEWEE} from './muationsType'
export default {
	[COOKIE_SHOW] (state, value) {
		state.cookieTips = value || true
	},
	[COOKIE_HIDE](state, value) {
		state.cookieTips = value || false
	},
	[ADD_INTERVIEWEE] (state, object) {
		let flag = false
		let data = object.data
        if (object.type=='channel') {
        	console.log(data)
          state.channelInterviewee.map(item => {
	           if (data&&item.id == data.id) {
	           	 flag = true
	           	 return
	           } 
			})
			if (!flag) {
	           state.channelInterviewee.push(data)
			}
        } else {
        	state.interviewee.map(item => {
	           if (data&&item.id == data.id) {
	           	 flag = true
	           	 return
	           } 
			})
			if (!flag) {
	           state.interviewee.push(data)
			}
        }
		
	},
	[REMOVE_INTERVIEWEE](state, object) {
		let data = object.data
		if (object.type=='channel') {
			state.channelInterviewee.map((item, index) => {
	          if (data&&item.id == data.id) {
	          	state.channelInterviewee.splice(index, 1)
	          }
			})
		} else {
			state.interviewee.map((item, index) => {
	          if (data&&item.id == data.id) {
	          	state.interviewee.splice(index, 1)
	          }
			})
		}
		
	},
	[CLEAR_INTERVIEWEE](state, object) {
		let type = object.type
		if (type == 'channel') {
		   state.channelInterviewee = []
		   console.log('===')
		} else {
           state.interviewee = []
		}
	}
}