1- import React , { useState } from 'react' ;
1+ import React , { useState , useContext } from 'react' ;
22import './SearchInput.scss' ;
3+ import { ReduxTestCaseContext } from '../../context/reducers/reduxTestCaseReducer' ;
34
45const SearchInput = ( {
56 dispatch,
@@ -16,6 +17,7 @@ const SearchInput = ({
1617 const [ filteredOptions , setFilteredOptions ] = useState ( [ ] ) ;
1718 const [ showOptions , setShowOptions ] = useState ( false ) ;
1819 const [ userInput , setUserInput ] = useState ( '' ) ;
20+ const [ , dispatchToReduxTestCase ] = useContext ( ReduxTestCaseContext ) ;
1921
2022 const handleChange = ( e ) => {
2123 const input = e . currentTarget . value ;
@@ -38,7 +40,13 @@ const SearchInput = ({
3840
3941 const selectedOption = e . target . type ;
4042 const filePath = filePathMap [ selectedOption ] || '' ;
41- if ( updateTypesFilePath ) dispatch ( updateTypesFilePath ( selectedOption , filePath , type ) ) ; //type));
43+ if ( updateTypesFilePath ) {
44+ if ( dispatchToReduxTestCase === dispatch ) {
45+ dispatch ( updateTypesFilePath ( selectedOption , filePath , 'reducer' ) ) ;
46+ dispatch ( updateTypesFilePath ( selectedOption , filePath , 'async' ) ) ;
47+ dispatch ( updateTypesFilePath ( selectedOption , filePath , 'action-creator' ) ) ;
48+ } else dispatch ( updateTypesFilePath ( selectedOption , filePath , type ) ) ;
49+ } //type));
4250 if ( updateActionsFilePath ) dispatch ( updateActionsFilePath ( selectedOption , filePath , type ) ) ;
4351 if ( action ) dispatch ( action ( selectedOption , filePath ) ) ;
4452 } ;
@@ -51,7 +59,13 @@ const SearchInput = ({
5159 const selectedOption = filteredOptions [ activeOption ] ;
5260 const filePath = filePathMap [ selectedOption ] || '' ;
5361 if ( action ) dispatch ( action ( selectedOption , filePath ) ) ;
54- if ( updateTypesFilePath ) dispatch ( updateTypesFilePath ( selectedOption , filePath , type ) ) ; //type));
62+ if ( updateTypesFilePath ) {
63+ if ( dispatchToReduxTestCase === dispatch ) {
64+ dispatch ( updateTypesFilePath ( selectedOption , filePath , 'reducer' ) ) ;
65+ dispatch ( updateTypesFilePath ( selectedOption , filePath , 'async' ) ) ;
66+ dispatch ( updateTypesFilePath ( selectedOption , filePath , 'action-creator' ) ) ;
67+ } else dispatch ( updateTypesFilePath ( selectedOption , filePath , type ) ) ;
68+ } //type));
5569 } else if ( e . keyCode === 38 ) {
5670 if ( activeOption === 0 ) {
5771 return ;
0 commit comments