settings.js 687 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /* eslint no-param-reassign: 0 */
  2. const state = {
  3. originalUser: {},
  4. modifiedUser: {}
  5. };
  6. const getters = {
  7. isGithubLinked: state => state.modifiedUser.github,
  8. isPasswordLinked: state => state.modifiedUser.password
  9. };
  10. const actions = {
  11. updateOriginalUser: ({ commit }, property, value) => {
  12. commit("updateOriginalUser", property, value);
  13. },
  14. setUser: ({ commit }, user) => {
  15. commit("setUser", user);
  16. }
  17. };
  18. const mutations = {
  19. updateOriginalUser(state, property, value) {
  20. state.originalUser[property] = value;
  21. },
  22. setUser(state, user) {
  23. state.originalUser = state.modifiedUser = user;
  24. }
  25. };
  26. export default {
  27. namespaced: true,
  28. state,
  29. getters,
  30. actions,
  31. mutations
  32. };