new look / search list / restaurant view

This commit is contained in:
2020-07-24 20:27:05 +02:00
parent 2ab445670e
commit ad2a945965
14 changed files with 208 additions and 44 deletions

View File

@@ -68,3 +68,40 @@ export const setAppMode = (mode) => {
type: mode,
};
};
export const setRestaurant = (restaurant) => {
return {
type: "SET_RESTAURANT",
payload: restaurant,
};
};
export const fetchRestaurant = (id) => {
return function (dispatch) {
axios
.get("http://localhost:4000/restaurant?restaurantId=" + id)
.then((response) => {
dispatch(setRestaurant(response.data));
dispatch(setAppMode("APP_RESTAURANT"));
dispatch(fetchAllDishes(id));
})
.catch((err) => console.log(err));
};
};
const setDishes = (data) => {
return {
type: "SET_DISHES",
payload: data,
};
};
export const fetchAllDishes = (id) => {
return function (dispatch) {
axios
.get("http://localhost:4000/restaurant/dishes?restaurantId=" + id)
.then((response) => {
dispatch(setDishes(response.data));
});
};
};