+ autocomplete + thunk

This commit is contained in:
2020-07-21 19:39:56 +02:00
parent 29efa13410
commit 2bcbfef8ba
16 changed files with 255 additions and 38 deletions

22
src/reducers/appMode.js Normal file
View 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;

View 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
View 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;

View 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;