import { connect } from 'dva/index';
import React, { Component } from 'react';
import { Form, Tabs } from 'antd';
import { sldLlineRtextAddGoodsAddMargin,sldComLanguage } from '@/utils/utils';
import global from '@/global.less';
import DiyLists from './diy_lists';
import InstanceTemplateLists from './instance_template_lists';
import BusinessStateSelector from "@/components/BusinessStateSelector"

const TabPane = Tabs.TabPane;
@connect(({ product }) => ({
  product,
}))
@Form.create()
export default class StorePCDiyIndex extends Component {
  constructor(props) {
    super(props);
    this.state = {
      activeKey: '1',
    };
  }
  componentDidMount() {
    if(this.props.location.query.tab!=undefined&&this.props.location.query.tab){
      this.setState({activeKey:this.props.location.query.tab})
    }
  }

  onHandleTabClick = (e) => {
    this.setState({activeKey:e})
  }

  renderHeaderTip = () => {
      return (
        <span className={global.common_header_tip}>
          <span>{'('}</span>
          <span>{sldComLanguage('将店铺状态设为')}</span>
          <span className={global.common_header_tip_text}>{`“${sldComLanguage('经营中')}”`}</span>
          <span>{'，'}</span>
          <span>{sldComLanguage('立即上线营业')}</span>
          <span>{' )'}</span>
        </span>
      )
  }

  confirmModal = () => {
    this.setState({activeKey: '2'})
  }

  render() {
    const {activeKey} = this.state;
    return (
      <div className={global.common_page} style={{ flex: 1 }}>
        <div style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center' }}>
            {sldLlineRtextAddGoodsAddMargin('#69A2F2', `${sldComLanguage('店铺装修')}`, 0, 0, 10, this.renderHeaderTip())}
            <BusinessStateSelector confirmModal={this.confirmModal}/>
        </div>
        <Tabs type="card" activeKey={activeKey} animated={false} onTabClick={this.onHandleTabClick}>
          <TabPane tab={`${sldComLanguage('实例化模板')}`} key="1">
            <InstanceTemplateLists/>
          </TabPane>
          <TabPane tab={`${sldComLanguage('首页装修')}`} key="2">
            <DiyLists/>
          </TabPane>
        </Tabs>
      </div>
    );
  }
}
