@lancom/shared 0.0.407 → 0.0.409

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.
@@ -284,6 +284,9 @@ export default {
284
284
  removeUser(id) {
285
285
  return _delete(`admin/user/${id}`);
286
286
  },
287
+ fetchCustomers() {
288
+ return _get('admin/customers');
289
+ },
287
290
  fetchCustomerById(id) {
288
291
  return _get(`admin/customer/${id}`);
289
292
  },
@@ -142,6 +142,7 @@ export default {
142
142
  };
143
143
  },
144
144
  computed: {
145
+ ...mapGetters('auth', ['user']),
145
146
  ...mapGetters(['MESSAGES']),
146
147
  ...mapGetters(['country', 'currency', 'app', 'googleClickId']),
147
148
  ...mapGetters(['orderSettings']),
@@ -178,6 +179,7 @@ export default {
178
179
  const recaptchaToken = await this.getRecaptcha('create_order');
179
180
  await this.createOrder({
180
181
  ...this.order,
182
+ customer: this.user?._id,
181
183
  paymentStatus: paymentStatus || 'abandoned',
182
184
  recaptchaToken,
183
185
  products: this.entities,
@@ -74,6 +74,7 @@ export default {
74
74
  };
75
75
  },
76
76
  computed: {
77
+ ...mapGetters('auth', ['user']),
77
78
  ...mapGetters(['shop', 'country','currency', 'googleClickId']),
78
79
  ...mapGetters('cart', ['entities', 'notEmptySimpleProducts', 'cartPricing']),
79
80
  isPaymentOrder() {
@@ -95,6 +96,7 @@ export default {
95
96
  const recaptchaToken = await this.getRecaptcha('create_order');
96
97
  await this.createOrder({
97
98
  ...this.order,
99
+ customer: this.user?._id,
98
100
  recaptchaToken,
99
101
  products: this.entities,
100
102
  pricing: this.cartPricing,
@@ -268,6 +268,7 @@ export default {
268
268
  };
269
269
  },
270
270
  computed: {
271
+ ...mapGetters('auth', ['user']),
271
272
  ...mapGetters(['shop', 'country', 'currency', 'googleClickId']),
272
273
  ...mapGetters('order', ['orderData']),
273
274
  ...mapGetters('cart', [
@@ -332,6 +333,7 @@ export default {
332
333
  this.processing = true;
333
334
  const recaptchaToken = await this.getRecaptcha('create_order');
334
335
  await this.createOrder({
336
+ customer: this.user?._id,
335
337
  recaptchaToken,
336
338
  currency: this.currency?._id,
337
339
  googleClickId: this.googleClickId,
@@ -27,6 +27,7 @@ export default {
27
27
  }
28
28
  },
29
29
  computed: {
30
+ ...mapGetters('auth', ['user']),
30
31
  ...mapGetters(['MESSAGES']),
31
32
  ...mapGetters('quote', ['quote', 'option', 'proceedOption', 'selectedOption', 'depositInfo', 'shopContacts', 'quoteAddress', 'quoteId', 'options', 'gstTax']),
32
33
  ...mapGetters(['shop', 'country', 'currency', 'googleClickId'])
@@ -40,7 +41,7 @@ export default {
40
41
  async convertToOrder(option) {
41
42
  try {
42
43
  this.processing = true;
43
- this.order = await this.createOrder({ ...option });
44
+ this.order = await this.createOrder({ ...option, customer: this.user?._id });
44
45
  this.setOrder(this.order);
45
46
  // gtm.purchase(this.order, this.currency);
46
47
  gapis.surveyOptin(this.order, this.shop);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.407",
3
+ "version": "0.0.409",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/index.js CHANGED
@@ -54,7 +54,7 @@ export const getters = {
54
54
  };
55
55
 
56
56
  export const actions = {
57
- async nuxtClientInit({ commit }, context) {
57
+ async nuxtClientInit({ commit, state: { shop } }, context) {
58
58
  try {
59
59
  const auth = getAuthToken();
60
60
  if (auth) {
@@ -63,6 +63,11 @@ export const actions = {
63
63
  } catch (e) {
64
64
  console.log('nuxtClientInit: ', e);
65
65
  }
66
+
67
+ if (!shop._id) {
68
+ shop = await api.fetchShopByUrl(process.env.HOST_NAME);
69
+ await commit('setShop', shop);
70
+ }
66
71
  },
67
72
  async nuxtServerInit({ commit }, { req }) {
68
73
  const shop = await api.fetchShopByUrl(process.env.HOST_NAME);