text: import React, { Component } from 'react';
  import {Tab,Tabs} from 'react-bootstrap'
  import MyOrders from './MyOrders'
  import MyAccount from './Myaccount'
  import {connect} from 'react-redux'
  import {img_baseurl} from '../../Configs/apibase'
  import MyAddresses from './MyAddresses';
  import Swal from 'sweetalert2';
  import Axios from 'axios';
  import Dashboard from './Dashboard'
  class CustomerAccount extends Component {
      constructor(props) {
          super(props);
          this.state = {
              name:'',
              active:1,
              loading:true
          }
      }
      componentDidMount(){
          let senderdata = {
              token:window.localStorage.getItem('key1')
            }
  
            Axios.post('/api/check_customer_auth',senderdata).then(res=>{
  
              if(res.data.status == 200){
                 this.setState({
                  customer:res.data.cus[0]
                 },function(){
                  this.setState({
                      loading:false
                  })
                 })
              }else{
                  // this.setState({
                  //     loading:false
                  // })
                  Swal.fire({
                      icon: 'error',
                      title: 'Sorry You Are not logged in Please Login.',
                      showConfirmButton: false,
                      timer: 1500
                      })
                  this.props.history.push('/login/profile');
              }
  
            })
      }
      logout(){
          window.localStorage.setItem('key1','null');
          window.location.reload();
        }
      render() {
          return (
  
              <div className="container">
                   <h2 className="" style={{marginTop:'130px'}}>Profile</h2>
                  {
  
                     this.state.loading ?
                     <div id="displayspinner py-5 mb-5" style={{ display: 'block', marginLeft: '45%', marginTop: '10%' , marginBottom:'20%'}}>
                              <div className="spinner-border text-info ml-2 spinner_format"  role="status">
                                  <span className="sr-only">Loading...</span>
                              </div>
                          </div>
                      :<>
                      <div className=" mt-5">
  
  
                  <div className="col-12">
                      <Tabs defaultActiveKey="k1" id="uncontrolled-tab-example">
                          <Tab eventKey="k1" title="Dashboard">
                              <Dashboard id={this.state.customer.id}></Dashboard>
                          </Tab>
                          <Tab eventKey="k2" title="Account Information">
                              <MyAccount customer={this.state.customer}></MyAccount>
                          </Tab>
                          <Tab eventKey="k3" title="My Orders" >
                              <MyOrders {...this.props} customer={this.state.customer}></MyOrders>
                          </Tab>
                          <Tab  eventKey="k4" title="Log Out" >
                              <div className="mt-5 p-5 mb-5 ">
                                  <button onClick={this.logout.bind(this)} className="btn btn-outline-danger">Logout</button>
                              </div>
                              <div className="mb-5"></div>
                          </Tab>
                      </Tabs>
                  </div>
                  </div>
                  </>
                  }
  
  
              </div>
          );
      }
  }
  const mapStateToProps = (state)=>{
      return {
          user:state.user
      }
    }
  
  export default connect(mapStateToProps)(CustomerAccount);
  