redesign and fixes

This commit is contained in:
2021-02-05 19:57:06 +01:00
parent c712d614e1
commit 611b101e9e
15 changed files with 243 additions and 50 deletions

View File

@@ -23,7 +23,7 @@ const initialState = {
backdrop: false,
tempData: {},
filters: {
type: [],
types: [],
tags: []
}
};
@@ -89,21 +89,24 @@ const data = (state = initialState, action) => {
case "HIDE_BACKDROP":
return (state = { ...state, backdrop: false });
case "UPDATE_RESTAURANT":
const index = state.userData.restaurants.findIndex((restaurant) => restaurant._id === action.payload._id);
return (state = {
...state,
userData: {
...state.userData,
restaurants: state.userData.restaurants.map((restaurant) => {
if (restaurant._id === action.payload._id) {
return action.payload;
} else {
return restaurant;
}
}),
restaurants: [
...state.userData.restaurants.slice(0, index),
action.payload,
...state.userData.restaurants.slice(index + 1)
],
},
});
case "SET_NEW_TOKEN":
return (state = {...state, userData: {...state.userData, jwt: action.payload}})
case "SET_TYPES":
return (state = {...state, filters: {...state.filters, types: action.payload}})
case "SET_TAGS":
return (state = {...state, filters: {...state.filters, tags: action.payload}})
default:
return state;
}