@lancom/shared 0.0.465 → 0.0.466

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.
@@ -128,6 +128,9 @@ export default {
128
128
  orderSubOrders(body) {
129
129
  return _post('admin/sub-orders/ordered', body);
130
130
  },
131
+ saveSubOrder(subOrder) {
132
+ return _put(`admin/sub-order/${subOrder._id}`, subOrder);
133
+ },
131
134
  generateOrderPickPDF(orderId) {
132
135
  return _post(`admin/order/${orderId}/pick-pdf`);
133
136
  },
@@ -312,7 +315,7 @@ export default {
312
315
  return _delete(`admin/inventory-history/${id}`);
313
316
  },
314
317
  fetchInventory(params) {
315
- return _get('admin/inventory');
318
+ return _get('admin/inventory', params);
316
319
  },
317
320
  fetchProducts(params) {
318
321
  return _get('admin/products', params);
@@ -2,7 +2,8 @@ export const PRINT_TYPES = {
2
2
  BLACK: 'black print',
3
3
  FULL_COLOUR: 'full colour print',
4
4
  EMBROIDERY: 'embroidery',
5
- SCREEN: 'screen print'
5
+ SCREEN: 'screen print',
6
+ REFLECTIVE: 'reflective'
6
7
  };
7
8
 
8
9
  export const PRINT_TYPES_LIST = Object.keys(PRINT_TYPES).map(k => PRINT_TYPES[k]);
@@ -16,6 +16,7 @@ export default {
16
16
  ...mapGetters(['shop', 'country', 'currency']),
17
17
  ...mapGetters('auth', ['user']),
18
18
  ...mapGetters('cart', [
19
+ 'loadingCart',
19
20
  'needToPickup',
20
21
  'needToPickupWithoutErrors',
21
22
  'entities',
@@ -60,7 +61,10 @@ export default {
60
61
  }
61
62
  },
62
63
  mounted() {
63
- this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country, currency: this.currency });
64
+ // console.log('this.loadingCart: ', this.loadingCart);
65
+ // if (!this.loadingCart) {
66
+ // this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country, currency: this.currency });
67
+ // }
64
68
  if (!this.suburb && this.user?.suburb) {
65
69
  this.handleSuburbChange(this.user.suburb);
66
70
  }
@@ -77,7 +77,7 @@
77
77
  <div
78
78
  v-else
79
79
  class="lc_caption lc_text-centered Cart__no-entities">
80
- Your cart is empty.
80
+ {{ loadingCart ? 'Your cart is loading...' : 'Your cart is empty.' }}
81
81
  </div>
82
82
  </div>
83
83
  </template>
@@ -115,7 +115,7 @@ export default {
115
115
  },
116
116
  computed: {
117
117
  ...mapGetters(['MESSAGES', 'SETTINGS', 'currency', 'country']),
118
- ...mapGetters('cart', ['isEmpty', 'cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities', 'entitiesWithoutFreeProducts']),
118
+ ...mapGetters('cart', ['isEmpty', 'cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities', 'entitiesWithoutFreeProducts', 'loadingCart']),
119
119
  productsEntities() {
120
120
  return this.entitiesWithoutFreeProducts.filter(e => !e.productsKit);
121
121
  },
@@ -30,7 +30,7 @@
30
30
  <div
31
31
  v-else
32
32
  class="lc_caption lc_text-centered Cart__no-entities">
33
- Your cart is empty.
33
+ {{ loadingCart ? 'Your cart is loading...' : 'Your cart is empty.' }}
34
34
  </div>
35
35
  </div>
36
36
  </template>
@@ -83,7 +83,7 @@ export default {
83
83
  },
84
84
  computed: {
85
85
  ...mapGetters('country'),
86
- ...mapGetters('cart', ['isEmpty']),
86
+ ...mapGetters('cart', ['isEmpty', 'loadingCart']),
87
87
  ...mapGetters('order', ['orderData']),
88
88
  ...mapGetters('auth', ['isAuthenticated', 'user']),
89
89
  steps() {
@@ -181,7 +181,9 @@
181
181
  <div class="lc_regular16">
182
182
  Total inc {{ taxName }}: <b>{{ model.totalGST | price(order.currency) }}</b>
183
183
  </div>
184
- <div class="lc_regular16">
184
+ <div
185
+ class="lc_regular16"
186
+ style="background-color: #000; color: #fff; padding: 4px 8px; display: inline-block;">
185
187
  {{ isPaid ? 'Paid' : 'Pending Payment' }}: <b>{{ model.totalGST | price(order.currency) }}</b>
186
188
  </div>
187
189
  </div>
@@ -229,7 +231,9 @@
229
231
  <div class="lc_regular16">
230
232
  Total inc {{ taxName }}: <b>{{ model.totalGST | price(order.currency) }}</b>
231
233
  </div>
232
- <div class="lc_regular16">
234
+ <div
235
+ class="lc_regular16"
236
+ style="background-color: #000; color: #fff; padding: 4px 8px; display: inline-block;">
233
237
  {{ isPaid ? 'Paid' : 'Pending Payment' }}: <b>{{ model.totalGST | price(order.currency) }}</b>
234
238
  </div>
235
239
  </div>
@@ -69,7 +69,7 @@ export default {
69
69
  data() {
70
70
  return {
71
71
  orderPrintTypes: [{
72
- types: ['black print', 'full colour print'],
72
+ types: ['black print', 'full colour print', 'reflective'],
73
73
  icon: 'printed',
74
74
  name: 'DIGITAL',
75
75
  subName: '',
@@ -1,10 +1,10 @@
1
1
  <template>
2
- <a
3
- :href="link"
2
+ <nuxt-link
3
+ :to="link"
4
4
  class="ProductsLink"
5
5
  rel="nofollow">
6
6
  <slot></slot>
7
- </a>
7
+ </nuxt-link>
8
8
  </template>
9
9
 
10
10
  <script>
@@ -43,6 +43,10 @@ const productPreview = {
43
43
  type: Boolean,
44
44
  default: true
45
45
  },
46
+ visibleQuickView: {
47
+ type: Boolean,
48
+ default: false
49
+ },
46
50
  linkTarget: {
47
51
  type: String,
48
52
  default: '_self'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.465",
3
+ "version": "0.0.466",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
@@ -2,7 +2,6 @@ import debounce from 'lodash.debounce';
2
2
 
3
3
  const STATE_STORAGE_KEY = 'lancom-state-2.3';
4
4
  const SAVE_STATE_MODULES = new Map([
5
- ['setGoogleClickId', 'googleClickId'],
6
5
  ['cart/setId', 'cart.id'],
7
6
  ['cart/clearCart', 'cart.id'],
8
7
  ['cart/setCoupon', 'cart.coupon'],
package/store/cart.js CHANGED
@@ -11,6 +11,7 @@ export const state = () => ({
11
11
  id: null,
12
12
  entities: [],
13
13
  needToPickup: false,
14
+ loadingCart: false,
14
15
  suburb: null,
15
16
  coupon: null,
16
17
  cartPricingCalculating: false,
@@ -103,6 +104,7 @@ export const getters = {
103
104
  return freeProducts.length > 0 ? sum + amount : sum;
104
105
  }, 0);
105
106
  },
107
+ loadingCart: ({ loadingCart }) => loadingCart,
106
108
  coupon: ({ coupon }) => coupon,
107
109
  needToPickup: ({ needToPickup }) => needToPickup,
108
110
  needToPickupWithoutErrors: (state, { notValidProductsPickup }) => state.needToPickup && notValidProductsPickup?.length === 0,
@@ -229,25 +231,28 @@ export const actions = {
229
231
  await api.saveCart(payload, shop._id);
230
232
  commit('setCartSaving', false);
231
233
  },
232
- async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, getters: { needToPickup }, commit }, { shop, country, currency }) {
233
- let savedSuppliersWithRates = null;
234
- try {
235
- savedSuppliersWithRates = JSON.parse(localStorage.getItem(SUPPLIERS_WITH_RATES_KEY));
236
- } catch (e) {}
237
- const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates || savedSuppliersWithRates;
238
- const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates, country, currency);
239
- console.log('calculateCartPrice:payload: ', payload)
240
- try {
241
- commit('setCartPricingCalculating', true);
242
- const response = await api.calculateProductPrice({ ...payload, needToPickup }, shop._id);
243
- commit('setCartPricing', response);
244
- commit('setCartPricingError', null);
245
- } catch (e) {
246
- const { error = 'Error calculate pricing' } = e.response?.data || {};
247
- commit('setCartPricingError', error);
248
- commit('setCartPricing', null);
249
- } finally {
250
- commit('setCartPricingCalculating', false);
234
+ async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing, loadingCart }, getters: { needToPickup }, commit }, { shop, country, currency }) {
235
+ if (!loadingCart) {
236
+ console.trace();
237
+ let savedSuppliersWithRates = null;
238
+ try {
239
+ savedSuppliersWithRates = JSON.parse(localStorage.getItem(SUPPLIERS_WITH_RATES_KEY));
240
+ } catch (e) {}
241
+ const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates || savedSuppliersWithRates;
242
+ const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates, country, currency);
243
+ console.log('calculateCartPrice:payload: ', payload)
244
+ try {
245
+ commit('setCartPricingCalculating', true);
246
+ const response = await api.calculateProductPrice({ ...payload, needToPickup }, shop._id);
247
+ commit('setCartPricing', response);
248
+ commit('setCartPricingError', null);
249
+ } catch (e) {
250
+ const { error = 'Error calculate pricing' } = e.response?.data || {};
251
+ commit('setCartPricingError', error);
252
+ commit('setCartPricing', null);
253
+ } finally {
254
+ commit('setCartPricingCalculating', false);
255
+ }
251
256
  }
252
257
  },
253
258
  async setSimpleProductAmount({ state, commit }, { guid, amount, shop, currency }) {
@@ -310,6 +315,10 @@ export const actions = {
310
315
  };
311
316
 
312
317
  export const mutations = {
318
+ setLoadingCart(state, loadingCart) {
319
+ state.loadingCart = loadingCart;
320
+ console.log('state.loadingCart: ', state.loadingCart);
321
+ },
313
322
  setCart(state, cart) {
314
323
  state.id = cart?._id;
315
324
  state.entities = cart?.entities || [];
package/store/index.js CHANGED
@@ -5,7 +5,18 @@ import { getShopCountrySettings } from '@lancom/shared/assets/js/utils/shop';
5
5
  import { MESSAGES, COUNTRIES_MESSAGES } from '@/messages';
6
6
  import { SETTINGS, COUNTRIES_SETTINGS } from '@/settings';
7
7
  const cookieparser = process.server ? require('cookieparser') : undefined;
8
+ const Cookies = process.browser ? require('js-cookie') : undefined;
8
9
  const CLOSED_NOTIFICATION = 'lancom-closed-notification-1.0';
10
+ const GCLID_COOKIE = 'gclid';
11
+ const GCLID_EXPIRE_DAYS = 90;
12
+
13
+ function getGclidCookie() {
14
+ return Cookies?.get(GCLID_COOKIE) || null;
15
+ }
16
+
17
+ function setGclidCookie(value) {
18
+ Cookies?.set(GCLID_COOKIE, value, { expires: GCLID_EXPIRE_DAYS, path: '/' });
19
+ }
9
20
 
10
21
  export const state = () => ({
11
22
  googleClickId: null,
@@ -108,6 +119,7 @@ export const actions = {
108
119
  }
109
120
  },
110
121
  async loadState({ dispatch, commit, state: { shop, currency, country, notificationBar } }, query) {
122
+ console.log('loadState...', query);
111
123
  const state = await loadState(query);
112
124
  if (state) {
113
125
  commit('setState', state);
@@ -116,19 +128,31 @@ export const actions = {
116
128
  currency: currency?._id,
117
129
  country: country?._id
118
130
  };
119
- const cart = await api.fetchCartById(shop._id, state.cart?.id, params);
120
- commit('cart/setCart', cart);
121
- if (state.cart?.coupon) {
122
- try {
123
- const code = state.cart?.coupon.code || state.cart?.coupon;
124
- const coupon = await api.fetchCouponByCode(shop._id, code);
125
- commit('cart/setCoupon', coupon);
126
- } catch (e) {}
131
+ commit('cart/setLoadingCart', true);
132
+ try {
133
+ const cart = await api.fetchCartById(shop._id, state.cart?.id, params);
134
+ commit('cart/setCart', cart);
135
+ if (state.cart?.coupon) {
136
+ try {
137
+ const code = state.cart?.coupon.code || state.cart?.coupon;
138
+ const coupon = await api.fetchCouponByCode(shop._id, code);
139
+ commit('cart/setCoupon', coupon);
140
+ } catch (e) {}
141
+ }
142
+ dispatch('cart/calculateCartPrice', { shop, country });
143
+ } catch (e) {
144
+ } finally {
145
+ commit('cart/setLoadingCart', false);
127
146
  }
128
- dispatch('cart/calculateCartPrice', { shop, country });
129
147
  }
130
148
  }
131
- commit('setGoogleClickId', query.gclid || state?.googleClickId || null);
149
+
150
+ const cookieGclid = getGclidCookie();
151
+ const googleClickId = query.gclid || cookieGclid || null;
152
+ commit('setGoogleClickId', googleClickId);
153
+ if (query.gclid) {
154
+ setGclidCookie(query.gclid);
155
+ }
132
156
 
133
157
  const closedNotification = localStorage.getItem(CLOSED_NOTIFICATION);
134
158
  if (notificationBar?.text === closedNotification) {