Commit e575478e authored by Mattias J Duffy's avatar Mattias J Duffy
Browse files

favorites storage fixed

parent d2040517
......@@ -57,9 +57,9 @@ class Layout extends React.Component {
const facilities = localStorage.getItem('facilities')
this.props.setFacilities(facilities)
}
if(localStorage.getItem('favorites')){
const favorites = localStorage.getItem('favorites')
const favorites = JSON.parse(localStorage.getItem('favorites'))
console.log(favorites)
this.props.setAllFavorites(favorites);
}
......
......@@ -50,11 +50,11 @@ const favorites = (state = [], action) => {
switch(action.type) {
case ADD_FAVORITE_FACILITY:
newState = [...state,action.slug]
localStorage.setItem('favorites',newState)
localStorage.setItem('favorites',JSON.stringify(newState))
return newState;
case REMOVE_FAVORITE_FACILITY:
newState = state.filter(slug => slug !== action.slug);
localStorage.setItem('favorites',newState)
localStorage.setItem('favorites',JSON.stringify(newState))
return newState;
case SET_ALL_FAVORITES:
return action.favorites;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment