@lancom/shared 0.0.283 → 0.0.284

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.
@@ -65,11 +65,11 @@ export default {
65
65
  ]),
66
66
  handleSuburbChange(suburb) {
67
67
  this.setSuburb(suburb);
68
- this.calculateCartPrice({ shop: this.shop, country: this.country });
68
+ this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
69
69
  },
70
70
  handleCouponChange(coupon) {
71
71
  this.setCoupon(coupon);
72
- this.calculateCartPrice({ shop: this.shop, country: this.country });
72
+ this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
73
73
  },
74
74
  async removeSimpleProducts(simpleProducts) {
75
75
  const message = 'This will delete all items in this row, Press OK to continue or Cancel';
@@ -98,7 +98,7 @@ export default {
98
98
  },
99
99
  set(coupon) {
100
100
  this.setCoupon(coupon);
101
- this.calculateCartPrice({ shop: this.shop, country: this.country });
101
+ this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
102
102
  }
103
103
  }
104
104
  },
@@ -40,7 +40,7 @@ export default {
40
40
  };
41
41
  },
42
42
  computed: {
43
- ...mapGetters(['shop', 'country']),
43
+ ...mapGetters(['shop', 'country', 'currency']),
44
44
  ...mapGetters('cart', [
45
45
  'entities',
46
46
  'cartPricing',
@@ -61,7 +61,7 @@ export default {
61
61
  'calculateCartPrice'
62
62
  ]),
63
63
  async calculatePrice() {
64
- await this.calculateCartPrice({ shop: this.shop, country: this.country });
64
+ await this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
65
65
  }
66
66
  }
67
67
  };
@@ -33,7 +33,7 @@
33
33
  :class="{
34
34
  'CartShipmentsPricing__rate--disabled': rate.disabled
35
35
  }"
36
- @click="selectRate({ supplier, rate, shop, country })">
36
+ @click="selectRate({ supplier, rate, shop, country, currency })">
37
37
  <div class="CartShipmentsPricing__rate-info">
38
38
  <div class="CartShipmentsPricing__rate-icon">
39
39
  <checked-icon :checked="rate.selected" />
@@ -365,7 +365,7 @@ export default {
365
365
  }
366
366
  },
367
367
  computed: {
368
- ...mapGetters(['shop', 'country', 'MESSAGES']),
368
+ ...mapGetters(['shop', 'country', 'currency', 'MESSAGES']),
369
369
  ...mapGetters('cart', [
370
370
  'suburb'
371
371
  ]),
@@ -419,7 +419,7 @@ export default {
419
419
  this.visibleFullAddress = true;
420
420
  this.setAddressSuburb(suburb);
421
421
  this.setSuburb(suburb);
422
- this.calculateCartPrice({ shop: this.shop, country: this.country });
422
+ this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
423
423
  }
424
424
  }
425
425
  };
@@ -45,7 +45,7 @@ export default {
45
45
  };
46
46
  },
47
47
  computed: {
48
- ...mapGetters(['shop', 'country']),
48
+ ...mapGetters(['shop', 'country', 'currency']),
49
49
  ...mapGetters('cart', ['cartPricing']),
50
50
  shippingPricing() {
51
51
  return this.cartPricing?.shipping;
@@ -53,7 +53,7 @@ export default {
53
53
  },
54
54
  mounted() {
55
55
  if (!this.shippingPricing) {
56
- this.calculateCartPrice({ shop: this.shop, country: this.country });
56
+ this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
57
57
  }
58
58
  },
59
59
  methods: {
@@ -116,11 +116,11 @@ export default {
116
116
  return {
117
117
  price: null,
118
118
  showDetails: false,
119
- calculatePriceWithDebounce: debounce(() => this.calculateProductPrice({ shop: this.shop, country: this.country }), 500)
119
+ calculatePriceWithDebounce: debounce(() => this.calculateProductPrice({ shop: this.shop, country: this.country, currency: this.currency }), 500)
120
120
  };
121
121
  },
122
122
  computed: {
123
- ...mapGetters(['shop', 'country']),
123
+ ...mapGetters(['shop', 'country', 'currency']),
124
124
  ...mapGetters('product', [
125
125
  'defaultSimpleProduct',
126
126
  'usedSimpleProducts',
@@ -12,10 +12,7 @@
12
12
  <editor-print-area-option
13
13
  :option="option"
14
14
  :product="product"
15
- :selected="
16
- (option.printArea && option.printArea._id === selected) ||
17
- (option.suboptions && option.printArea && option.printArea._id === selected)
18
- "
15
+ :selected="option.printArea && option.printArea._id === selected"
19
16
  @select="select"
20
17
  @option-mouseover="$emit('option-mouseover', $event)"
21
18
  @option-mouseleave="$emit('option-mouseleave', $event)" />
@@ -52,41 +49,33 @@ export default {
52
49
  default: false
53
50
  }
54
51
  },
55
- data() {
56
- return {
57
- options: []
58
- };
59
- },
60
- watch: {
61
- side() {
62
- this.updateOptions();
52
+ computed: {
53
+ options() {
54
+ const groupItemToOption = printArea => ({ printArea, label: printArea.name, size: printArea.printSize.alias });
55
+ const productsOptions = (this.product.printAreas || [])
56
+ .map(printArea => {
57
+ const mainOption = { ...groupItemToOption(printArea), sides: [printArea.side] };
58
+ const suboptions = [
59
+ mainOption,
60
+ ...(printArea.sizes || []).map(i => ({ ...groupItemToOption({ ...i, side: printArea.side }), sides: [printArea.side] }))
61
+ ];
62
+ return {
63
+ ...(suboptions.find(s => s.printArea?._id === this.selected) || mainOption),
64
+ suboptions
65
+ };
66
+ });
67
+ const options = productsOptions.filter(({ sides }) => sides.includes(this.side));
68
+ return this.allowNoPrint ? [...options, { label: 'No Print' }] : options;
63
69
  }
64
70
  },
65
71
  mounted() {
66
- this.updateOptions();
72
+ if (!this.selected) {
73
+ this.select(this.options[0]);
74
+ }
67
75
  },
68
76
  methods: {
69
- updateOptions() {
70
- const productsOptions = this.getProductOptions();
71
- const options = productsOptions.filter(({ sides }) => sides.includes(this.side));
72
- this.options = this.allowNoPrint ? [...options, { label: 'No Print' }] : options;
73
-
74
- this.select(this.options[0]);
75
- },
76
77
  select(option) {
77
78
  this.$emit('select', option);
78
- },
79
- getProductOptions() {
80
- const groupItemToOption = printArea => ({ printArea, label: printArea.name, size: printArea.printSize.alias });
81
- return (this.product.printAreas || [])
82
- .map(printArea => ({
83
- ...groupItemToOption(printArea),
84
- sides: [printArea.side],
85
- suboptions: [
86
- { ...groupItemToOption(printArea), sides: [printArea.side] },
87
- ...(printArea.sizes || []).map(i => ({ ...groupItemToOption(i), sides: [printArea.side] }))
88
- ]
89
- }));
90
79
  }
91
80
  }
92
81
  };
@@ -93,7 +93,7 @@
93
93
  v-if="productDetailsLoaded"
94
94
  ref="areaOptions"
95
95
  :product="product"
96
- :selected="selectedPrintArea && selectedPrintArea._id"
96
+ :selected="editablePrintArea && editablePrintArea._id"
97
97
  :side="editableSide.id"
98
98
  @select="selectPrintArea"
99
99
  @option-mouseover="toogleBoundBox(true, $event)"
@@ -347,7 +347,7 @@ export default {
347
347
  this.form.suburb = suburb;
348
348
  this.setAddressSuburb(suburb);
349
349
  this.setSuburb(suburb);
350
- this.calculateCartPrice({ shop: this.shop, country: this.country });
350
+ this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
351
351
  },
352
352
  back() {
353
353
  this.switchModal('showCartModal');
@@ -139,7 +139,7 @@ export default {
139
139
  };
140
140
  },
141
141
  computed: {
142
- ...mapGetters(['shop', 'country', 'taxName']),
142
+ ...mapGetters(['shop', 'country', 'currency', 'taxName']),
143
143
  printsPricing() {
144
144
  return this.productPricing?.products[this.product._id]?.prints.prints || [];
145
145
  }
@@ -152,7 +152,7 @@ export default {
152
152
  const prints = this.generateSidesPrints();
153
153
  const layers = prints.map(({ printType, printSize, printArea }) => ({ printType: printType?._id, printSize: printSize?._id, printArea: printArea?._id }));
154
154
  const entities = getProductsForCalculatePricing(this.product, [this.simpleProduct], layers, true, true);
155
- this.productPricing = await api.calculateProductPrice({ entities, country: this.country?._id }, this.shop._id);
155
+ this.productPricing = await api.calculateProductPrice({ entities, country: this.country?._id, currency: this.currency?._id }, this.shop._id);
156
156
  },
157
157
  generateSidesPrints() {
158
158
  return this.sides
@@ -216,7 +216,7 @@ export default {
216
216
  };
217
217
  },
218
218
  computed: {
219
- ...mapGetters(['shop', 'country']),
219
+ ...mapGetters(['shop', 'country', 'currency']),
220
220
  maxScreenPrintColors() {
221
221
  const printTypes = this.product.printTypes.filter(printType => printType.type === 'screen print');
222
222
  return Math.max(...printTypes.map(printType => printType.colorsQuantity));
@@ -262,7 +262,7 @@ export default {
262
262
  const prints = this.generateSidesPrints(type);
263
263
  const layers = prints.map(({ printType, printSize, printArea }) => ({ printType: printType?._id, printSize: printSize?._id, printArea: printArea?._id }));
264
264
  const entities = getProductsForCalculatePricing(this.product, [this.simpleProduct], layers, true, true);
265
- const pricing = await api.calculateProductPrice({ entities, postcode: this.postcode, country: this.country?._id }, this.shop._id);
265
+ const pricing = await api.calculateProductPrice({ entities, postcode: this.postcode, country: this.country?._id, currency: this.currency?._id }, this.shop._id);
266
266
  return { pricing, prints, type };
267
267
  })
268
268
  );
@@ -119,7 +119,7 @@ export default {
119
119
  return {
120
120
  price: null,
121
121
  showDetails: false,
122
- calculatePriceWithDebounce: debounce(() => this.calculateProductPrice({ shop: this.shop, country: this.country }), 500)
122
+ calculatePriceWithDebounce: debounce(() => this.calculateProductPrice({ shop: this.shop, country: this.country, currency: this.currency }), 500)
123
123
  };
124
124
  },
125
125
  props: {
@@ -58,7 +58,7 @@ async function googleShoppingFeed(axios, config, availableStores, country) {
58
58
  'g:id': { _text: sp.SKU },
59
59
  'g:item_group_id': { _text: product.SKU },
60
60
  'g:size': { _text: sp.size.name },
61
- 'g:size_system': 'AU',
61
+ 'g:size_system': country || 'AU',
62
62
  'g:size_type': 'regular',
63
63
  'g:gender': { _text: product.gender },
64
64
  'g:material': { _text: product.fabricInfoShort },
@@ -68,7 +68,7 @@ async function googleShoppingFeed(axios, config, availableStores, country) {
68
68
  'g:color': { _text: sp.color.name },
69
69
  'g:image_link': { _text: sp.image || image },
70
70
  'g:additional_image_link': (sp.image ? [image, ...images] : images).map(i => ({ _text: i })),
71
- 'g:price': { _text: `${(sp.price || 0)} ${sp.currency || 'AUD'}` },
71
+ 'g:price': { _text: `${(sp.price || 0)} ${sp.currencyCode || 'AUD'}` },
72
72
  'g:availability': { _text: sp.quantityStock > 0 ? 'in_stock' : 'out_of_stock' },
73
73
  'g:google_product_category': { _text: product.feedGoogleProductCategory || 2047 },
74
74
  'g:product_type': { _text: product.feedProductType || `Home > Products > ${product.productType.name}`, },
@@ -52,7 +52,7 @@ export default {
52
52
 
53
53
  this.clearTemplate(true);
54
54
 
55
- this.calculateCartPrice({ shop: this.shop, country: this.country });
55
+ this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
56
56
 
57
57
  // this.resetLayers();
58
58
  // this.setIsPrintPricing(false);
@@ -22,7 +22,7 @@ const productsPrice = {
22
22
  };
23
23
  },
24
24
  computed: {
25
- ...mapGetters(['pricingSettings', 'shop', 'country']),
25
+ ...mapGetters(['pricingSettings', 'shop', 'country', 'currency']),
26
26
  printsPricing() {
27
27
  const pricing = {};
28
28
  if (this.productPricing) {
@@ -73,7 +73,8 @@ const productsPrice = {
73
73
  products: this.calcProducts,
74
74
  postcode: this.postcode,
75
75
  screenPrint: this.screenPrint,
76
- country: this.country?._id
76
+ country: this.country?._id,
77
+ currency: this.currency?._id
77
78
  };
78
79
  this.productPricing = await api.calculateProductPrice(playload, this.shop._id);
79
80
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.283",
3
+ "version": "0.0.284",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/cart.js CHANGED
@@ -153,9 +153,9 @@ export const actions = {
153
153
  await api.saveCart(payload, shop._id);
154
154
  commit('setEntities', entities);
155
155
  },
156
- async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, commit }, { shop, country }) {
156
+ async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, commit }, { shop, country, currency }) {
157
157
  const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates;
158
- const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates, country);
158
+ const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates, country, currency);
159
159
  console.log('calculateCartPrice:payload: ', payload)
160
160
  try {
161
161
  commit('setCartPricingCalculating', true);
@@ -186,7 +186,7 @@ export const actions = {
186
186
  clearCart({ commit }) {
187
187
  commit('clearCart');
188
188
  },
189
- async selectRate({ state: { cartPricing, entities, suburb, coupon }, commit }, { supplier, rate, shop, country }) {
189
+ async selectRate({ state: { cartPricing, entities, suburb, coupon }, commit }, { supplier, rate, shop, country, currency }) {
190
190
  const suppliersWithRates = cartPricing.shipping.suppliersWithRates
191
191
  .map(supplierWithRates => ({
192
192
  ...(
@@ -197,7 +197,7 @@ export const actions = {
197
197
  })
198
198
  : supplierWithRates)
199
199
  }));
200
- const payload = generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon, null, country);
200
+ const payload = generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon, null, country, currency);
201
201
  try {
202
202
  commit('setCartPricingCalculating', true);
203
203
  const response = await api.calculateProductPrice(payload, shop._id);
@@ -254,7 +254,7 @@ export const mutations = {
254
254
  }
255
255
  };
256
256
 
257
- function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon, selectedSuppliersWithRates, country) {
257
+ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon, selectedSuppliersWithRates, country, currency) {
258
258
  const getSimpleObj = i => i && ({ _id: i._id, name: i.name });
259
259
  return {
260
260
  entities: entities.map(({ _id, guid, prints, simpleProducts, product }) => ({
@@ -295,6 +295,7 @@ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon
295
295
  coupon,
296
296
  suppliersWithRates,
297
297
  selectedSuppliersWithRates,
298
- country: country?._id
298
+ country: country?._id,
299
+ currency: currency?._id
299
300
  };
300
301
  }
package/store/product.js CHANGED
@@ -201,10 +201,10 @@ export const actions = {
201
201
  async updatePriceIncludeGST({ commit }, value) {
202
202
  commit('setPriceIncludeGST', value);
203
203
  },
204
- async calculateProductPrice({ state: { template, product, isPrintPricing }, commit, getters }, { shop, country }) {
204
+ async calculateProductPrice({ state: { template, product, isPrintPricing }, commit, getters }, { shop, country, currency }) {
205
205
  commit('setCalculatingPrice', true);
206
206
  const entities = getProductsForCalculatePricing(product, getters.usedSimpleProducts, template.layers, isPrintPricing, true);
207
- const response = await api.calculateProductPrice({ entities, country: country?._id }, shop._id);
207
+ const response = await api.calculateProductPrice({ entities, country: country?._id, currency: currency?._id }, shop._id);
208
208
  commit('setProductPricing', response);
209
209
  commit('setCalculatingPrice', false);
210
210
  },