+ autocomplete + thunk
This commit is contained in:
22
src/reducers/appMode.js
Normal file
22
src/reducers/appMode.js
Normal file
@@ -0,0 +1,22 @@
|
||||
const appModeReducer = (state = "init", action) => {
|
||||
switch (action.type) {
|
||||
case "APP_INIT":
|
||||
return (state = "init");
|
||||
case "APP_SEARCH_RESULTS":
|
||||
return (state = "search results");
|
||||
case "APP_LOGIN":
|
||||
return (state = "login");
|
||||
case "APP_RESTAURANT":
|
||||
return (state = "restaurant");
|
||||
case "APP_DISH":
|
||||
return (state = "dish");
|
||||
case "APP_ADD_RESTAURANT":
|
||||
return (state = "add restaurant");
|
||||
case "APP_ADD_DISH":
|
||||
return (state = "add dish");
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default appModeReducer;
|
||||
12
src/reducers/autoComplete.js
Normal file
12
src/reducers/autoComplete.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const autoCompleteReducer = (state = [], action) => {
|
||||
switch (action.type) {
|
||||
case "AUTOCOMPLETE_ADD":
|
||||
return action.payload;
|
||||
case "AUTOCOMPLETE_CLEAR":
|
||||
return (state = []);
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default autoCompleteReducer;
|
||||
12
src/reducers/index.js
Normal file
12
src/reducers/index.js
Normal file
@@ -0,0 +1,12 @@
|
||||
import { combineReducers } from "redux";
|
||||
import autoCompleteReducer from "./autoComplete";
|
||||
import searchResults from "./searchResults";
|
||||
import appMode from "./appMode";
|
||||
|
||||
const rootReducer = combineReducers({
|
||||
autocomplete: autoCompleteReducer,
|
||||
appMode: appMode,
|
||||
searchResults: searchResults,
|
||||
});
|
||||
|
||||
export default rootReducer;
|
||||
12
src/reducers/searchResults.js
Normal file
12
src/reducers/searchResults.js
Normal file
@@ -0,0 +1,12 @@
|
||||
const searchResults = (state = {}, action) => {
|
||||
switch (action.type) {
|
||||
case "SEARCH_RESULTS":
|
||||
return action.payload;
|
||||
case "SEARCH_CLEAR":
|
||||
return (state = {});
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
||||
|
||||
export default searchResults;
|
||||
Reference in New Issue
Block a user