/*
 * Copyright © 2016-2017 European Support Limited
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import React from 'react';
import PropTypes from 'prop-types';
import {connect} from 'react-redux';

const mapStateToProps = ({loader}) => {
	return {
		isLoading: loader.isLoading
	};
};

class Loader extends React.Component {

	static propTypes = {
		isLoading: PropTypes.bool.isRequired
	};

	static defaultProps = {
		isLoading: false
	};

	shouldComponentUpdate(nextProps) {
		return (nextProps.isLoading !== this.props.isLoading);
	}

	render() {
		let {isLoading} = this.props;
		return (
			<div className='onboarding-loader'>
				{
					isLoading && <div className='onboarding-loader-backdrop'>
						<div className='tlv-loader large'></div>
					</div>
				}
			</div>
		);
	}
}

export default connect(mapStateToProps) (Loader);
