@fleetbase/storefront-engine 0.3.13 → 0.3.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/addon/components/add-product-as-entity-button.js +3 -3
  2. package/addon/components/modals/create-first-store.hbs +3 -1
  3. package/addon/components/widget/storefront-key-metrics.hbs +1 -1
  4. package/addon/controllers/application.js +1 -1
  5. package/addon/controllers/products/index/category/edit.js +1 -0
  6. package/addon/controllers/products/index/category/new.js +6 -2
  7. package/addon/routes/application.js +14 -3
  8. package/addon/routes/customers/index/edit.js +14 -1
  9. package/addon/routes/customers/index/view.js +11 -0
  10. package/addon/routes/customers/index.js +11 -0
  11. package/addon/routes/networks/index/network.js +11 -0
  12. package/addon/routes/networks/index.js +11 -0
  13. package/addon/routes/orders/index/edit.js +14 -1
  14. package/addon/routes/orders/index/new.js +14 -1
  15. package/addon/routes/orders/index/view.js +10 -0
  16. package/addon/routes/orders/index.js +11 -0
  17. package/addon/routes/products/index/category/edit.js +11 -0
  18. package/addon/routes/products/index/category/new.js +15 -1
  19. package/addon/routes/products/index/category.js +12 -1
  20. package/addon/routes/products/index/index.js +11 -0
  21. package/addon/routes/products/index.js +11 -0
  22. package/addon/routes/settings/index.js +11 -0
  23. package/addon/services/storefront.js +35 -74
  24. package/addon/templates/application.hbs +31 -5
  25. package/addon/templates/customers/index.hbs +1 -1
  26. package/addon/templates/networks/index.hbs +4 -3
  27. package/addon/templates/orders/index.hbs +2 -2
  28. package/addon/templates/products/index/category/new.hbs +326 -245
  29. package/addon/templates/products/index/category.hbs +6 -9
  30. package/addon/templates/products/index/index.hbs +2 -2
  31. package/addon/templates/products/index.hbs +11 -5
  32. package/addon/templates/settings/index.hbs +1 -0
  33. package/composer.json +3 -3
  34. package/config/environment.js +6 -0
  35. package/extension.json +1 -1
  36. package/package.json +6 -5
  37. package/server/config/database.connections.php +15 -1
  38. package/server/src/Auth/Schemas/Storefront.php +97 -3
  39. package/server/src/Http/Controllers/v1/CartController.php +1 -1
  40. package/server/src/Http/Controllers/v1/CustomerController.php +1 -1
  41. package/server/src/Http/Resources/Product.php +5 -5
  42. package/server/src/Models/Cart.php +1 -1
  43. package/server/src/Models/Network.php +3 -3
  44. package/server/src/Models/Store.php +4 -4
  45. package/server/src/Support/Metrics.php +8 -8
  46. package/server/src/Support/QPay.php +4 -4
  47. package/translations/ar-ae.yml +642 -0
  48. package/translations/vi-vn.yaml +648 -0
@@ -40,12 +40,12 @@ export default class AddProductAsEntityButtonComponent extends Component {
40
40
  this.order.meta.pushObjects([
41
41
  {
42
42
  key: 'storefront',
43
- value: selectedStorefront.name
43
+ value: selectedStorefront.name,
44
44
  },
45
45
  {
46
46
  key: 'storefront_id',
47
- value: selectedStorefront.public_id
48
- }
47
+ value: selectedStorefront.public_id,
48
+ },
49
49
  ]);
50
50
  }
51
51
  })
@@ -15,18 +15,20 @@
15
15
  @name={{t "storefront.component.modals.create-first-store.storefront-name"}}
16
16
  @value={{@options.store.name}}
17
17
  @helpText={{t "storefront.component.modals.create-first-store.enter-name"}}
18
+ @disabled={{cannot "storefront create store"}}
18
19
  />
19
20
  <InputGroup
20
21
  @name={{t "storefront.component.modals.create-first-store.description"}}
21
22
  @value={{@options.store.description}}
22
23
  @helpText={{t "storefront.component.modals.create-first-store.brief-description"}}
24
+ @disabled={{cannot "storefront create store"}}
23
25
  />
24
26
  <InputGroup
25
27
  @name={{t "storefront.component.modals.create-first-store.currency"}}
26
28
  @value={{@options.store.currency}}
27
29
  @helpText={{t "storefront.component.modals.create-first-store.select-currency"}}
28
30
  >
29
- <CurrencySelect @currency={{@options.store.currency}} @onCurrencyChange={{fn (mut @options.store.currency)}} @triggerClass="w-full form-select" />
31
+ <CurrencySelect @currency={{@options.store.currency}} @onCurrencyChange={{fn (mut @options.store.currency)}} @triggerClass="w-full form-select" @disabled={{cannot "storefront create store"}} />
30
32
  </InputGroup>
31
33
  </div>
32
34
  </div>
@@ -10,7 +10,7 @@
10
10
  {{else}}
11
11
  <div class="grid grid-cols-2 lg:grid-cols-12 gap-4">
12
12
  {{#each-in this.metrics as |title options|}}
13
- <Dashboard::Count @title={{smart-humanize title}} @options={{options}} />
13
+ <Widget::Count @title={{smart-humanize title}} @options={{options}} class="lg:col-span-2 h-full" />
14
14
  {{/each-in}}
15
15
  </div>
16
16
  {{/if}}
@@ -12,7 +12,7 @@ export default class ApplicationController extends Controller {
12
12
  @action createNewStorefront() {
13
13
  return this.storefront.createNewStorefront({
14
14
  onSuccess: () => {
15
- const loader = this.loader.show({ loadingMessage: `Switching to newly created store...` });
15
+ const loader = this.loader.show({ loadingMessage: 'Switching to newly created store...' });
16
16
 
17
17
  this.hostRouter.refresh().then(() => {
18
18
  this.notifyPropertyChange('activeStore');
@@ -11,6 +11,7 @@ export default class ProductsIndexCategoryEditController extends ProductsIndexCa
11
11
  @tracked overlayActionButtonTitle = 'Save Changes';
12
12
  @tracked overlayActionButtonIcon = 'save';
13
13
  @tracked overlayExitButtonTitle = 'Done';
14
+ abilityPermission = 'storefront update product';
14
15
 
15
16
  get overlayTitle() {
16
17
  return `Edit ${this.product.name}`;
@@ -26,6 +26,7 @@ export default class ProductsIndexCategoryNewController extends BaseController {
26
26
  @tracked uploadedFiles = [];
27
27
  @tracked primaryFile = null;
28
28
  @tracked isSaving = false;
29
+ abilityPermission = 'storefront create product';
29
30
 
30
31
  /** overlay options */
31
32
  @tracked overlayTitle = 'New Product';
@@ -66,10 +67,13 @@ export default class ProductsIndexCategoryNewController extends BaseController {
66
67
 
67
68
  this.loader.removeLoader(loader);
68
69
  this.notifications.success(this.intl.t('storefront.products.index.new.new-product-created-success'));
69
-
70
+
70
71
  try {
71
72
  yield this.transitionToRoute('products.index.category', category.slug);
72
- } catch (error) {}
73
+ } catch (error) {
74
+ this.notifications.serverError(error);
75
+ }
76
+
73
77
  this.reset();
74
78
  }
75
79
 
@@ -8,20 +8,31 @@ export default class ApplicationRoute extends Route {
8
8
  @service loader;
9
9
  @service currentUser;
10
10
  @service modalsManager;
11
- // @service theme;
11
+ @service notifications;
12
+ @service hostRouter;
13
+ @service abilities;
14
+ @service intl;
12
15
  @service storefront;
13
16
 
14
17
  @action loading(transition) {
15
18
  this.loader.showOnInitialTransition(transition, 'section.next-view-section', { loadingMessage: 'Loading storefront...' });
16
19
  }
17
20
 
21
+ @action error(error) {
22
+ this.notifications.serverError(error);
23
+ }
24
+
18
25
  @action willTransition() {
19
26
  this.modalsManager.done();
20
27
  }
21
28
 
22
29
  beforeModel() {
23
- this.disableSandbox();
30
+ if (this.abilities.cannot('storefront see extension')) {
31
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
32
+ return this.hostRouter.transitionTo('console');
33
+ }
24
34
 
35
+ this.disableSandbox();
25
36
  return this.fetch.get('actions/store-count', {}, { namespace: 'storefront/int/v1' }).then(({ storeCount }) => {
26
37
  // if no store count prompt to create a store
27
38
  if (!storeCount) {
@@ -40,7 +51,7 @@ export default class ApplicationRoute extends Route {
40
51
  }
41
52
  }
42
53
 
43
- @action disableSandbox() {
54
+ disableSandbox() {
44
55
  this.currentUser.setOption('sandbox', false);
45
56
  // this.theme.setEnvironment();
46
57
  }
@@ -1,3 +1,16 @@
1
1
  import Route from '@ember/routing/route';
2
+ import { inject as service } from '@ember/service';
2
3
 
3
- export default class CustomersIndexEditRoute extends Route {}
4
+ export default class CustomersIndexEditRoute extends Route {
5
+ @service intl;
6
+ @service abilities;
7
+ @service hostRouter;
8
+ @service notifications;
9
+
10
+ beforeModel() {
11
+ if (this.abilities.cannot('storefront update customer')) {
12
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
13
+ return this.hostRouter.transitionTo('console.storefront');
14
+ }
15
+ }
16
+ }
@@ -3,11 +3,22 @@ import { inject as service } from '@ember/service';
3
3
 
4
4
  export default class CustomersIndexViewRoute extends Route {
5
5
  @service store;
6
+ @service intl;
7
+ @service abilities;
8
+ @service hostRouter;
9
+ @service notifications;
6
10
 
7
11
  queryParams = {
8
12
  view: { refreshModel: false },
9
13
  };
10
14
 
15
+ beforeModel() {
16
+ if (this.abilities.cannot('storefront view customer')) {
17
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
18
+ return this.hostRouter.transitionTo('console.storefront');
19
+ }
20
+ }
21
+
11
22
  model({ public_id }) {
12
23
  return this.store.findRecord('contact', public_id);
13
24
  }
@@ -6,6 +6,10 @@ import isNestedRouteTransition from '@fleetbase/ember-core/utils/is-nested-route
6
6
  export default class CustomersIndexRoute extends Route {
7
7
  @service store;
8
8
  @service storefront;
9
+ @service intl;
10
+ @service abilities;
11
+ @service hostRouter;
12
+ @service notifications;
9
13
 
10
14
  queryParams = {
11
15
  page: { refreshModel: true },
@@ -29,6 +33,13 @@ export default class CustomersIndexRoute extends Route {
29
33
  }
30
34
  }
31
35
 
36
+ beforeModel() {
37
+ if (this.abilities.cannot('storefront list customer')) {
38
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
39
+ return this.hostRouter.transitionTo('console.storefront');
40
+ }
41
+ }
42
+
32
43
  model(params) {
33
44
  return this.store.query('customer', { ...params, storefront: this.storefront.getActiveStore('public_id') });
34
45
  }
@@ -3,6 +3,17 @@ import { inject as service } from '@ember/service';
3
3
 
4
4
  export default class NetworksIndexNetworkRoute extends Route {
5
5
  @service store;
6
+ @service intl;
7
+ @service abilities;
8
+ @service hostRouter;
9
+ @service notifications;
10
+
11
+ beforeModel() {
12
+ if (this.abilities.cannot('storefront view network')) {
13
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
14
+ return this.hostRouter.transitionTo('console.storefront');
15
+ }
16
+ }
6
17
 
7
18
  model({ public_id }) {
8
19
  return this.store.findRecord('network', public_id);
@@ -5,6 +5,10 @@ import isNestedRouteTransition from '@fleetbase/ember-core/utils/is-nested-route
5
5
 
6
6
  export default class NetworksIndexRoute extends Route {
7
7
  @service store;
8
+ @service intl;
9
+ @service abilities;
10
+ @service hostRouter;
11
+ @service notifications;
8
12
 
9
13
  queryParams = {
10
14
  page: { refreshModel: true },
@@ -22,6 +26,13 @@ export default class NetworksIndexRoute extends Route {
22
26
  }
23
27
  }
24
28
 
29
+ beforeModel() {
30
+ if (this.abilities.cannot('storefront list network')) {
31
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
32
+ return this.hostRouter.transitionTo('console.storefront');
33
+ }
34
+ }
35
+
25
36
  model(params) {
26
37
  return this.store.query('network', { with_gateways: 1, with_notification_channels: 1, ...params });
27
38
  }
@@ -1,3 +1,16 @@
1
1
  import Route from '@ember/routing/route';
2
+ import { inject as service } from '@ember/service';
2
3
 
3
- export default class OrdersIndexEditRoute extends Route {}
4
+ export default class OrdersIndexEditRoute extends Route {
5
+ @service intl;
6
+ @service abilities;
7
+ @service hostRouter;
8
+ @service notifications;
9
+
10
+ beforeModel() {
11
+ if (this.abilities.cannot('storefront update order')) {
12
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
13
+ return this.hostRouter.transitionTo('console.storefront');
14
+ }
15
+ }
16
+ }
@@ -1,3 +1,16 @@
1
1
  import Route from '@ember/routing/route';
2
+ import { inject as service } from '@ember/service';
2
3
 
3
- export default class OrdersIndexNewRoute extends Route {}
4
+ export default class OrdersIndexNewRoute extends Route {
5
+ @service intl;
6
+ @service abilities;
7
+ @service hostRouter;
8
+ @service notifications;
9
+
10
+ beforeModel() {
11
+ if (this.abilities.cannot('storefront create order')) {
12
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
13
+ return this.hostRouter.transitionTo('console.storefront');
14
+ }
15
+ }
16
+ }
@@ -7,11 +7,21 @@ export default class OrdersIndexViewRoute extends Route {
7
7
  @service notifications;
8
8
  @service store;
9
9
  @service socket;
10
+ @service intl;
11
+ @service abilities;
12
+ @service hostRouter;
10
13
 
11
14
  @action error(error) {
12
15
  this.notifications.serverError(error);
13
16
  }
14
17
 
18
+ beforeModel() {
19
+ if (this.abilities.cannot('storefront view order')) {
20
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
21
+ return this.hostRouter.transitionTo('console.storefront');
22
+ }
23
+ }
24
+
15
25
  model({ public_id }) {
16
26
  const order = this.store.queryRecord('order', {
17
27
  public_id,
@@ -6,6 +6,10 @@ import isNestedRouteTransition from '@fleetbase/ember-core/utils/is-nested-route
6
6
  export default class OrdersIndexRoute extends Route {
7
7
  @service store;
8
8
  @service storefront;
9
+ @service intl;
10
+ @service abilities;
11
+ @service hostRouter;
12
+ @service notifications;
9
13
 
10
14
  queryParams = {
11
15
  page: { refreshModel: true },
@@ -33,6 +37,13 @@ export default class OrdersIndexRoute extends Route {
33
37
  }
34
38
  }
35
39
 
40
+ beforeModel() {
41
+ if (this.abilities.cannot('storefront list order')) {
42
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
43
+ return this.hostRouter.transitionTo('console.storefront');
44
+ }
45
+ }
46
+
36
47
  model(params) {
37
48
  return this.store.query('order', { ...params, storefront: this.storefront.getActiveStore('public_id') });
38
49
  }
@@ -4,8 +4,19 @@ import { filterHasManyForNewRecords } from '../../../../serializers/product';
4
4
 
5
5
  export default class ProductsIndexCategoryEditRoute extends Route {
6
6
  @service store;
7
+ @service intl;
8
+ @service abilities;
9
+ @service hostRouter;
10
+ @service notifications;
7
11
  templateName = 'products.index.category.new';
8
12
 
13
+ beforeModel() {
14
+ if (this.abilities.cannot('storefront update product')) {
15
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
16
+ return this.hostRouter.transitionTo('console.storefront');
17
+ }
18
+ }
19
+
9
20
  model({ public_id }) {
10
21
  return this.store.queryRecord('product', {
11
22
  public_id,
@@ -1,9 +1,23 @@
1
1
  import Route from '@ember/routing/route';
2
+ import { inject as service } from '@ember/service';
3
+ import { action } from '@ember/object';
2
4
 
3
5
  export default class ProductsIndexCategoryNewRoute extends Route {
4
- didTransition() {
6
+ @service intl;
7
+ @service abilities;
8
+ @service hostRouter;
9
+ @service notifications;
10
+
11
+ @action didTransition() {
5
12
  if (this.controller) {
6
13
  this.controller.reset();
7
14
  }
8
15
  }
16
+
17
+ beforeModel() {
18
+ if (this.abilities.cannot('storefront create product')) {
19
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
20
+ return this.hostRouter.transitionTo('console.storefront');
21
+ }
22
+ }
9
23
  }
@@ -7,6 +7,10 @@ export default class ProductsIndexCategoryRoute extends Route {
7
7
  @service store;
8
8
  @service currentUser;
9
9
  @service loader;
10
+ @service intl;
11
+ @service abilities;
12
+ @service hostRouter;
13
+ @service notifications;
10
14
  @tracked categorySlug;
11
15
 
12
16
  queryParams = {
@@ -26,10 +30,17 @@ export default class ProductsIndexCategoryRoute extends Route {
26
30
  }
27
31
  }
28
32
 
29
- loading(transition) {
33
+ @action loading(transition) {
30
34
  this.loader.showOnInitialTransition(transition, 'section.next-view-section', { loadingMessage: 'Loading products...' });
31
35
  }
32
36
 
37
+ beforeModel() {
38
+ if (this.abilities.cannot('storefront list product')) {
39
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
40
+ return this.hostRouter.transitionTo('console.storefront');
41
+ }
42
+ }
43
+
33
44
  model({ slug, ...params }) {
34
45
  this.categorySlug = slug;
35
46
 
@@ -4,6 +4,10 @@ import { inject as service } from '@ember/service';
4
4
  export default class ProductsIndexIndexRoute extends Route {
5
5
  @service store;
6
6
  @service currentUser;
7
+ @service intl;
8
+ @service abilities;
9
+ @service hostRouter;
10
+ @service notifications;
7
11
 
8
12
  queryParams = {
9
13
  page: { refreshModel: true },
@@ -16,6 +20,13 @@ export default class ProductsIndexIndexRoute extends Route {
16
20
  updated_at: { refreshModel: true },
17
21
  };
18
22
 
23
+ beforeModel() {
24
+ if (this.abilities.cannot('storefront list product')) {
25
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
26
+ return this.hostRouter.transitionTo('console.storefront');
27
+ }
28
+ }
29
+
19
30
  model(params) {
20
31
  return this.store.query('product', { store_uuid: this.currentUser.getOption('activeStorefront'), ...params });
21
32
  }
@@ -6,6 +6,10 @@ import isNestedRouteTransition from '@fleetbase/ember-core/utils/is-nested-route
6
6
  export default class ProductsIndexRoute extends Route {
7
7
  @service store;
8
8
  @service currentUser;
9
+ @service intl;
10
+ @service abilities;
11
+ @service hostRouter;
12
+ @service notifications;
9
13
 
10
14
  @action willTransition(transition) {
11
15
  this.controller.category = null;
@@ -16,6 +20,13 @@ export default class ProductsIndexRoute extends Route {
16
20
  }
17
21
  }
18
22
 
23
+ beforeModel() {
24
+ if (this.abilities.cannot('storefront list product')) {
25
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
26
+ return this.hostRouter.transitionTo('console.storefront');
27
+ }
28
+ }
29
+
19
30
  model(params = {}) {
20
31
  return this.store.query('category', {
21
32
  for: 'storefront_product',
@@ -5,6 +5,17 @@ export default class SettingsIndexRoute extends Route {
5
5
  @service store;
6
6
  @service currentUser;
7
7
  @service storefront;
8
+ @service intl;
9
+ @service abilities;
10
+ @service hostRouter;
11
+ @service notifications;
12
+
13
+ beforeModel() {
14
+ if (this.abilities.cannot('storefront view settings')) {
15
+ this.notifications.warning(this.intl.t('common.unauthorized-access'));
16
+ return this.hostRouter.transitionTo('console');
17
+ }
18
+ }
8
19
 
9
20
  model() {
10
21
  return this.store.peekRecord('store', this.currentUser.getOption('activeStorefront'));
@@ -7,47 +7,14 @@ import { get } from '@ember/object';
7
7
  * Service to manage storefront operations.
8
8
  */
9
9
  export default class StorefrontService extends Service.extend(Evented) {
10
- /**
11
- * Ember service for data store.
12
- * @type {Service}
13
- */
14
10
  @service store;
15
-
16
- /**
17
- * Ember service for intl.
18
- * @type {Service}
19
- */
20
11
  @service intl;
21
-
22
- /**
23
- * Ember service for fetch operations.
24
- * @type {Service}
25
- */
26
12
  @service fetch;
27
-
28
- /**
29
- * Ember service for notifications.
30
- * @type {Service}
31
- */
32
13
  @service notifications;
33
-
34
- /**
35
- * Ember service for current user information.
36
- * @type {Service}
37
- */
38
14
  @service currentUser;
39
-
40
- /**
41
- * Ember service for managing modals.
42
- * @type {Service}
43
- */
44
15
  @service modalsManager;
45
-
46
- /**
47
- * Ember service for router operations.
48
- * @type {Service}
49
- */
50
16
  @service hostRouter;
17
+ @service abilities;
51
18
 
52
19
  /**
53
20
  * Gets the active store.
@@ -137,18 +104,17 @@ export default class StorefrontService extends Service.extend(Evented) {
137
104
  backdropClose: false,
138
105
  order,
139
106
  store,
140
- confirm: (modal) => {
107
+ confirm: async (modal) => {
141
108
  modal.startLoading();
142
109
 
143
- return this.fetch
144
- .post('orders/accept', { order: order.id }, { namespace: 'storefront/int/v1' })
145
- .then(() => {
146
- this.trigger('order.accepted', order);
147
- modal.stopLoading();
148
- })
149
- .catch((error) => {
150
- this.notifications.serverError(error);
151
- });
110
+ try {
111
+ await this.fetch.post('orders/accept', { order: order.id }, { namespace: 'storefront/int/v1' });
112
+ this.trigger('order.accepted', order);
113
+ modal.done();
114
+ } catch (error) {
115
+ modal.stopLoading();
116
+ this.notifications.serverError(error);
117
+ }
152
118
  },
153
119
  });
154
120
  }
@@ -201,6 +167,7 @@ export default class StorefrontService extends Service.extend(Evented) {
201
167
  title: this.intl.t('storefront.service.storefront.create-first-storefront'),
202
168
  acceptButtonIcon: 'check',
203
169
  acceptButtonIconPrefix: 'fas',
170
+ acceptButtonDisabled: this.abilities.cannot('storefront create store'),
204
171
  closeButton: false,
205
172
  backdropClose: false,
206
173
  keyboard: true,
@@ -209,20 +176,18 @@ export default class StorefrontService extends Service.extend(Evented) {
209
176
  declineButtonIcon: 'times',
210
177
  declineButtonIconPrefix: 'fas',
211
178
  store,
212
- confirm: (modal, done) => {
179
+ confirm: async (modal) => {
213
180
  modal.startLoading();
214
181
 
215
- store
216
- .save()
217
- .then((store) => {
218
- this.notifications.success(this.intl.t('storefront.service.storefront.storefront-has-been-create-success'));
219
- this.setActiveStorefront(store);
220
- return done();
221
- })
222
- .catch((error) => {
223
- modal.stopLoading();
224
- this.notifications.serverError(error);
225
- });
182
+ try {
183
+ await store.save();
184
+ this.notifications.success(this.intl.t('storefront.service.storefront.storefront-has-been-create-success'));
185
+ this.setActiveStorefront(store);
186
+ modal.done();
187
+ } catch (error) {
188
+ modal.stopLoading();
189
+ this.notifications.serverError(error);
190
+ }
226
191
  },
227
192
  decline: () => {
228
193
  this.hostRouter.transitionTo('console');
@@ -250,26 +215,22 @@ export default class StorefrontService extends Service.extend(Evented) {
250
215
  declineButtonIcon: 'times',
251
216
  declineButtonIconPrefix: 'fas',
252
217
  store,
253
- confirm: (modal, done) => {
218
+ confirm: async (modal) => {
254
219
  modal.startLoading();
255
220
 
256
- store
257
- .save()
258
- .then((store) => {
259
- this.notifications.success(this.intl.t('storefront.service.storefront.storefront-create-success'));
260
- // this.currentUser.setOption('activeStorefront', store.id);
261
- this.setActiveStorefront(store);
262
-
263
- if (typeof options?.onSuccess === 'function') {
264
- options.onSuccess(store);
265
- }
266
-
267
- return done();
268
- })
269
- .catch((error) => {
270
- modal.stopLoading();
271
- this.notifications.serverError(error);
272
- });
221
+ try {
222
+ const store = await store.save();
223
+ this.notifications.success(this.intl.t('storefront.service.storefront.storefront-create-success'));
224
+ // this.currentUser.setOption('activeStorefront', store.id);
225
+ this.setActiveStorefront(store);
226
+ if (typeof options?.onSuccess === 'function') {
227
+ options.onSuccess(store);
228
+ }
229
+ modal.done();
230
+ } catch (error) {
231
+ modal.stopLoading();
232
+ this.notifications.serverError(error);
233
+ }
273
234
  },
274
235
  ...options,
275
236
  });