import React from 'react';
import {connect} from 'react-redux';
import AssessResult from '@components/AssessResult';
import {ISREAD} from '@store/types/homePage.js';
import {billing} from '@store/async-actions/pushMessage';
import {getAssessData,getIndexData} from '@store/async-actions/fetchModules';
import {SET_ASSESS_DATA,SET_INDEX_DATA} from '@types/assessResult';

function mapStateToProps(state) {
  //console.log(state)
  const {assessResult} = state;
  return {
    data:assessResult.data,
    indexData:assessResult.indexData
  }
}

function mapDispatchToProps(dispatch, store) {
  return {
    getAssess(){
      dispatch(getAssessData()).then((res)=>{
        if(res.data.code=='0'){
          dispatch({
            type:SET_ASSESS_DATA,
            data:res.data.data
          })
        }
      }).catch(error=>{
        console.log(error);
      });
    },
    getIndexData(){
      dispatch(getIndexData()).then((res)=>{
        if(res.data.code=='0'){
          dispatch({
            type:SET_INDEX_DATA,
            data:res.data.data
          })
        }
      }).catch(error=>{
        console.log(error);
      });
    }
  }
}

const AssessResultContainer = connect(mapStateToProps, mapDispatchToProps)(AssessResult);

export default AssessResultContainer;