const defState = () => ({
	network: {},
	time: '',
	dashboard: {
		ip: '',
		version: '',
		di: [],
		leone: []
	}
})

const sysinfoReducer = (state = defState(), action) => {
	switch(action.type) {
		case 'network_info':
			return {...state, network: action.network};
		case 'system_time':
			return {...state, time: action.time || ''};
		case 'dashboard':
			return {
				...state, 
				dashboard: {
					ip: action.ip,
					version: action.version,
					di: action.di,
					leone: action.leone
				}
			}
		case 'clear_dashboard':
			return {
				...state,
				dashboard:{
					...defState().dashboard
				}
			}
		default:
			return state;
	}
}

export default sysinfoReducer;