import React, { Component } from 'react';
import { Modal} from 'antd';
import axios from 'axios';
//加入精品课堂
class Jointheclass extends Component {

	constructor(props) {
		super(props);
	}

	componentDidMount() {
		// console.log("加入精品课堂");
		// console.log(this.props);

	}

	modalCancel=()=>{
   this.props.ysljoinmodalCancel();
	};

	setDownload=()=>{
		let id=this.props.Pathcourseid===undefined?this.props.match.params.coursesId:this.props.Pathcourseid
		let url = `/courses/${id}/join_excellent_course.json`;
		axios.post(url).then((result) => {
			if(result){
				if(result.data){
					if(result.data.status === 0){
						this.props.showNotification(result.data.message);
						this.props.ysljoinmodalCanceltwo();
					}else {
						this.props.showNotification(result.data.message);
					}
				}

			}
		}).catch((error) => {
			console.log(error)
		})

	}


	render() {
		// console.log("加入精品课堂2");
		 //console.log(this.props.Pathcourseid);
		return(
			<Modal
				keyboard={false}
				closable={false}
				footer={null}
				destroyOnClose={true}
				title="提示"
				centered={true}
				visible={this.props.yslJointhe===undefined?false:this.props.yslJointhe}
				width="600px"
			>
				<div className="educouddiv">
					<div className={"tabeltext-alignleft"}><p className={"mt70 mb70 font-16"}>是否确认该加入课堂?</p></div>
					<div className="clearfix  edu-txt-center mt20">
						<style>
							{
								`
							a:hover {
									color: #fff !important;
							}
							`
							}
						</style>
						<a className="task-btn mr30" onClick={()=>this.modalCancel()}>取消</a>
						<a className="task-btn task-btn-orange" onClick={()=>this.setDownload()}>确认</a>
					</div>
				</div>
			</Modal>
		)
	}
}

export default Jointheclass;