small fix

This commit is contained in:
2022-07-26 17:06:06 +02:00
parent 69f5f98b2a
commit 5ca5d0d0b9

View File

@@ -27,17 +27,21 @@ export const userSlice = createSlice({
(restaurant) => restaurant.id === action.payload.id
);
let restaurants: Restaurant[] = state.restaurants || [];
state = {
...state,
restaurants: [
...restaurants.slice(0, index),
action.payload,
...restaurants.slice(index + 1),
],
};
if (index != undefined) {
state = {
...state,
restaurants: [
...restaurants.slice(0, index),
action.payload,
...restaurants.slice(index + 1),
],
};
} else {
state = state;
}
},
},
});
export const { clearUserData } = userSlice.actions;
export const { clearUserData, updateRestaurant } = userSlice.actions;
export default userSlice.reducer;