/**
 * Clear Cart sub-component
 *
 * @type {*|Function}
 *
 * @author Rai Icasiano <ricasiano at cambridge dot org>
 */
window.ClearCart = React.createClass({
    clearCart: function() {
        this.props.setLoading(true);

        let successCallback = function () {
            window.location = '/education';
        };
        
        let failCallback = function (componentReference) {
            componentReference.props.setAPIError(true);
        };

        //API Call
        deleteCart(this, successCallback, failCallback);

    },
    displayModal: function () {
        this.props.setConfirmModal(true);
        this.props.setConfirmModalAction(this.clearCart);
        this.props.setConfirmModalErrorMessage('Clearing your cart will also return you to the homepage. Are you sure you want to do this?');
    },

    render: function () {
        return (<div className="three columns">
            <a data-reveal-id="clearCartModal" className="button large grey" href="#"
               onClick={this.displayModal} >Clear Cart</a>
        </div>);
    }
});