export const showSearch = (state,action) => {
    const res = Object.assign({}, state);
    res.show = true;
    return res;
}

export const hideSearch = (state,action) => {
    const res = Object.assign({}, state);
    res.show = false;
    return res;
}

export const setSearchValue = (state,action) => {
    const res = Object.assign({},state);
    res.searchValue = action.searchValue;
    return res;
}

export const getSearchResult= (state, action) => {
    const res = Object.assign({},state);
    let searchResult = []
    action.searchResult && action.searchResult.map((item, index) =>{
        let searchResultItem = {}
        searchResultItem.id = item.questionId
        searchResultItem.name = item.name
        searchResultItem.showType = item.showType
        searchResultItem.retrievalName = item.retrievalName
        searchResult.push(searchResultItem)
    }) 
    res.searchResult = searchResult;
    return res;
}
