'use strict';
import React from 'react';
import { connect } from  'react-redux';
import SwiperComponent from '../../components/CommonComponent/SwiperComponent/SwiperComponent'
import ImgToolComponent from '../../components/CommonComponent/CommonSmallComponent/ImgToolComponent/CommonSmalContainer'
import EditProblemItem from '../../components/OtherQuestionComponent/EditProblemComponent'
import {getOtherProblem} from '../../actions/otherQuestion'
require('./index.css');
export default class OtherQuestionContainer extends React.Component{
    constructor(props){
        super(props)
        this.state = {
            showCategoryElement:false,
            showDetailElement:false,
            currentLiIndex:0
        }
    }
    componentWillMount() {
        let {dispatch,initStart} = this.props;
        console.log(this.props);
        let postData = {};
        initStart(postData)

    }
    componentDidMount(){
    }
    componentDidUpdate() {
    }
    componentWillReceiveProps(nextProps){
    }
    componentWillUnmount(){
    }
    handleShowElement(value){
        console.log(value);
        console.log(this.state[value])
           this.setState(
               {
                   [value]:!this.state[value]
               }
           )
    }
    handleDetailProblem(event){
        this.setState({
            currentLiIndex: parseInt(event.currentTarget.getAttribute('date-index'))
        })
    }
    render(){
        //let 难道初始化的数据:
        let {state} = this.props;
        console.log(state)
        let {otherQuestion} = state;
        let {feeds,problems} = otherQuestion;
        let editProblemItemUI = '';
        let swiperCount = 0;
        feeds && feeds.length>0 ?(
            editProblemItemUI = feeds.map((i,k)=>{
                return <EditProblemItem  problemInfo = {problems} baseInfo = {feeds[k]}  key={k}/>;
            })
            ):""
        feeds && feeds.length>0 ?(
            swiperCount = feeds.length
        ):""

        let swiperOptions = {
            width : 1396,
            spaceBetween: 30,
            freeMode:true,
            // slidesPerView: 2.6,
        };
        let swiperContainer = CONFIG.swiperContainers.editProblemSwiperContainer;



        return (
            <div className={"OtherQuestionContainer"}>
                <div className={"otherQuestionTitleContainer"}>你是否有其他问题希望反馈(<i>*</i>必填项)</div>
                <div className={"editOtherQuestionContainer clearfix"}>
                    <SwiperComponent
                        swiperContainer={swiperContainer} swiperOptions={swiperOptions} swiperCount={swiperCount}
                    >
                        {editProblemItemUI}
                    </SwiperComponent>
                </div>
                <div className={"opeationContainer clearfix"}>
                    <button className={"addMoreBtn"}><span>+</span>录入更多</button>
                    <button className={"noMoreBtn"}>没有更多</button>
                </div>

            </div>
        )
    }
}