import React, { Component } from 'react'
import './study.scss'

import { NavLink, Route, Switch, Redirect } from "react-router-dom"
import MyCourses from "./myCourses"
import FreeCourses from './freeCourses'
import WithTab from '@/HOCs/WithTab'
import WithFullSize from '@/HOCs/WithFullSize'
import { compose } from 'redux'
import PrivateRoute from '@/router/privateRoute'


class Study extends Component {

    state = {
        position: {

        }
    }

    list;

    storeScrollPosition(tab){

    }

    render() {
        const {match} = this.props;
        return (
            <section id='study'>
                <div className='tab'>
                    <div>
                        <NavLink to={`${match.url}/my-course`}
                                 replace
                                 activeClassName='active'
                        >我的课程</NavLink>
                    </div>
                    <div>
                        <NavLink to={`${match.url}/free-course`}
                                 replace
                                 activeClassName='active'
                        >免费课程</NavLink>
                    </div>
                </div>
                <div className="study-container" ref={el => this.list = el}>
                    <Switch>
                        <Redirect exact from='/study' to='study/my-course'/>
                        <Route path={`${this.props.match.path}/my-course`} component={MyCourses}/>
                        {/*<PrivateRoute path={`${this.props.match.path}/my-course`} component={MyCourses}/>*/}
                        <Route path={`${this.props.match.path}/free-course`} component={FreeCourses}/>
                        {/*<Route path={`${this.props.match.path}/my-course`} render={props => {
                            <MyCourses storeScrollPosition={this.storeScrollPosition}/>
                        }}/>*/}
                    </Switch>
                </div>
            </section>
        )
    }

}

export default compose(
    WithFullSize,
    WithTab
)(Study)