redesign and fixes
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user