import React from 'react';
import { connect } from 'react-redux';
import { getSearchList } from '@store/async-actions/medicalInfo';
import MedicalInfo from '@components/MedicalInfo';
import {getAllConceptDetail} from '../store/async-actions/pushMessage';
import {getMedicalFilters} from '../store/async-actions/fetchModules';
import {CLEAR_INFO_SEARCH_LIST,SET_FILTER_LIST} from '@types/medicalInfo';

function mapStateToProps(state) {
    const {medicalInfo} = state;
    return{
        searchResult: medicalInfo.searchResult,
        filterList:medicalInfo.filterList
    }
}

function mapDispatchToProps(dispatch) {
    return {
        handleChangeValue(val,types){
            dispatch(getSearchList(val,types))
        },
        getAllConceptDetail(item) {
            dispatch(getAllConceptDetail(item))
        },
        clearResult(){
              dispatch({
                type:CLEAR_INFO_SEARCH_LIST
              })
        },
        getFilters(){
              getMedicalFilters().then((res)=>{
                  if(res.data.code=='0'){
                      dispatch({
                        type:SET_FILTER_LIST,
                        list:res.data.data[7]
                      })
                  }
              });
        }
    }
}
const MedicalInfoContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(MedicalInfo);

export default MedicalInfoContainer
