import React from 'react';
import { connect } from 'react-redux';
import { SHOW_SEARCH,  HIDE_SEARCH, GET_SEARCH_RESULT } from '@store/types/diagnosticSearch';
import { getSearchResult, getSearchList } from '@store/async-actions/diagnosticSearch';
import DiagResultSearch from '@components/DiagResultSearch';

function mapStateToProps(state) {
    return{
        show: state.diagnosticSearch.show,
        searchValue: state.diagnosticSearch.searchValue,
        searchResult: state.diagnosticSearch.searchResult,
    }
}

function mapDispatchToProps(dispatch) {
    return {
        showSearch:()=>{
            dispatch({
                type: SHOW_SEARCH
            })
        },
        hideSearch:()=>{
            dispatch({
                type: HIDE_SEARCH
            })
        },
        clearSearchResult: ()=>{
            dispatch({
                type: GET_SEARCH_RESULT,
                searchResult: []
            })
        },
        handleChangeValue: (val)=>{
            dispatch(getSearchList(val))
        }
    }
}

const DiagnosticSearchContainer = connect(
    mapStateToProps,
    mapDispatchToProps
)(DiagResultSearch);

export default DiagnosticSearchContainer
