{"size": 609, "ext": "js", "max_stars_repo_path": "src/store/plugins.js", "max_stars_repo_name": "theankitgaurav/group-expenses-pwa-client", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "src/store/plugins.js", "max_issues_repo_name": "theankitgaurav/group-expenses-pwa-client", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/store/plugins.js", "max_forks_repo_name": "theankitgaurav/group-expenses-pwa-client", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": null, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 38.0625, "max_line_length": 83, "alphanum_fraction": 0.6896551724}
import constants from '@/utils/constants';

const localStoragePlugin = store => {
  store.subscribe((mutation, { token, user, entriesList}) => {
    if (mutation.type === 'AUTH_SUCCESS') {
      window.localStorage.setItem(constants.TOKEN, JSON.stringify(token));
      window.localStorage.setItem(constants.USER, JSON.stringify(user));
    } else if (mutation.type === 'SET_EXPENSES') {
      window.localStorage.setItem(constants.EXPENSES, JSON.stringify(entriesList));
    } else if (mutation.type === 'AUTH_LOGOUT') {
      window.localStorage.clear();
    }
  });
};

export default [localStoragePlugin];