The Bubble web UI in VueJS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

73 lines
1.9 KiB

  1. /**
  2. * Copyright (c) 2020 Bubble, Inc. All rights reserved.
  3. * For personal (non-commercial) use, see license: https://getbubblenow.com/bubble-license/
  4. */
  5. import { domainService } from '~/_services';
  6. import { util } from '~/_helpers';
  7. const state = {
  8. loading: {
  9. domains: false, domain: false
  10. },
  11. error: null,
  12. domains: null,
  13. domain: null
  14. };
  15. const actions = {
  16. getAllDomains({ commit }, {userId, messages, errors}) {
  17. commit('getAllDomainsRequest');
  18. domainService.getAllDomains(userId, messages, errors)
  19. .then(
  20. domains => commit('getAllDomainsSuccess', domains),
  21. error => commit('getAllDomainsFailure', error)
  22. );
  23. },
  24. getDomainById({ commit }, {userId, domainId, messages, errors}) {
  25. commit('getDomainByIdRequest');
  26. domainService.getDomainById(userId, domainId, messages, errors)
  27. .then(
  28. domain => commit('getDomainByIdSuccess', domain),
  29. error => commit('getDomainByIdFailure', error)
  30. );
  31. }
  32. };
  33. const mutations = {
  34. getAllDomainsRequest(state) {
  35. state.loading.domains = true;
  36. },
  37. getAllDomainsSuccess(state, domains) {
  38. state.loading.domains = false;
  39. state.domains = domains;
  40. },
  41. getAllDomainsFailure(state, error) {
  42. state.loading.domains = false;
  43. state.error = { error };
  44. },
  45. getDomainByIdRequest(state) {
  46. state.loading.domain = true;
  47. },
  48. getDomainByIdSuccess(state, domain) {
  49. state.loading.domain = false;
  50. state.domain = domain;
  51. },
  52. getDomainByIdFailure(state, error) {
  53. state.loading.domain = false;
  54. state.error = { error };
  55. }
  56. };
  57. const getters = {
  58. loading: util.checkLoading(state.loading, 'domains')
  59. };
  60. export const domains = {
  61. namespaced: true,
  62. state,
  63. actions,
  64. mutations,
  65. getters
  66. };