@lancom/shared 0.0.158 → 0.0.160

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.
@@ -52,7 +52,7 @@ export function getColorBackgroundStyle(color) {
52
52
 
53
53
  if (pattern) {
54
54
  return {
55
- 'background-image': `url("${pattern}")`
55
+ 'background-image': `url("${staticLink(pattern)}")`
56
56
  };
57
57
  }
58
58
 
@@ -1,5 +1,6 @@
1
1
  import dayjs from 'dayjs';
2
2
  import DateOnly from 'dateonly';
3
+ import Vue from 'vue';
3
4
 
4
5
  import currencies from '../constants/currencies';
5
6
  import { printsLabels } from '../constants/prints';
@@ -88,7 +89,20 @@ export const sydneyTime = d => dayjs(d).utc().utcOffset(10).format('MMM D, YYYY
88
89
 
89
90
  export const priceInRange = (prices, amount) => ((prices || []).find(({ min, max }) => min <= amount && (!max || max >= amount)) || { price: 0 }).price;
90
91
 
91
- export const staticLink = link => (link || '').startsWith('http') ? link : `${process.env.STATIC_URL}${link}`;
92
+ export const staticLink = link => {
93
+ const { PROD_S3_BUCKET, DEV_S3_BUCKET, PROD_CDN_URL, DEV_CDN_URL, STATIC_URL } = Vue.$env;
94
+ if ((link || '').startsWith('http')) {
95
+ if (PROD_S3_BUCKET && PROD_CDN_URL) {
96
+ link = link.replace(new RegExp(`https://${PROD_S3_BUCKET}[a-z\-\.0-9]+.amazonaws.com`), PROD_CDN_URL);
97
+ }
98
+ if (DEV_S3_BUCKET && PROD_CDN_URL) {
99
+ link = link.replace(new RegExp(`https://${DEV_S3_BUCKET}[a-z\-\.0-9]+.amazonaws.com`), DEV_CDN_URL);
100
+ }
101
+ return link;
102
+ } else {
103
+ return `${STATIC_URL}${link}`;
104
+ };
105
+ }
92
106
 
93
107
  export const nl2br = text => text.replace(/\n/g, '<br>');
94
108
 
@@ -147,6 +147,7 @@
147
147
  'is-danger': errors.length,
148
148
  filled: address.addressLine1
149
149
  }"
150
+ @input="validateAddress"
150
151
  @keyup.enter="$refs.addressLine1.focus()" />
151
152
  <span
152
153
  v-if="errors.length"
@@ -176,6 +177,7 @@
176
177
  'is-danger': errors.length,
177
178
  filled: address.addressLine2
178
179
  }"
180
+ @input="validateAddress"
179
181
  @keyup.enter="$refs.addressLine2.focus()" />
180
182
  <span
181
183
  v-if="errors.length"
@@ -279,6 +281,9 @@ export default {
279
281
  }
280
282
  },
281
283
  methods: {
284
+ validateAddress() {
285
+ this.$refs.addressProvider.validate();
286
+ },
282
287
  ...mapMutations('cart', [
283
288
  'setSuburb'
284
289
  ]),
@@ -7,7 +7,9 @@
7
7
  <div v-if="creating">
8
8
  <spinner />
9
9
  </div>
10
- <div class="form-row OrderPaymentInformation__form">
10
+ <div
11
+ v-else
12
+ class="form-row OrderPaymentInformation__form">
11
13
  <label
12
14
  class="form-label OrderPaymentInformation__checkbox"
13
15
  @click="updatePaymentType(false)">
@@ -121,22 +123,24 @@ export default {
121
123
  }).join('</p><p>')}</p>`;
122
124
  },
123
125
  async submit() {
126
+ this.creating = true;
124
127
  this.errorMessage = null;
125
128
  if (this.isDepositPayment) {
126
129
  this.setCard(null);
127
- this.submitOrder();
130
+ await this.submitOrder();
128
131
  } else {
129
132
  let card = null;
130
133
  try {
131
134
  card = await this.$refs.paymentCart.tokenize();
132
135
  } catch (e) {
133
- this.handleErrors(e);
136
+ await this.handleErrors(e);
134
137
  }
135
138
  if (card) {
136
139
  this.setCard(card);
137
- this.submitOrder();
140
+ await this.submitOrder();
138
141
  }
139
142
  }
143
+ this.creating = false;
140
144
  // this.$emit('next');
141
145
  },
142
146
  async submitOrder() {
@@ -37,6 +37,7 @@
37
37
 
38
38
  <script>
39
39
  import { date } from '@lancom/shared/assets/js/utils/filters';
40
+ import { staticLink } from '@lancom/shared/assets/js/utils/filters';
40
41
 
41
42
  export default {
42
43
  name: 'NewsListItem',
@@ -54,7 +55,7 @@ export default {
54
55
  return `/news/${this.item.alias}`;
55
56
  },
56
57
  backgroundImage() {
57
- return this.item.image ? `url('${this.item.image.medium}')` : '';
58
+ return this.item.image ? `url('${staticLink(this.item.image.medium)}')` : '';
58
59
  }
59
60
  },
60
61
  methods: {
@@ -19,6 +19,7 @@
19
19
  v-hammer:panend="onPanend"
20
20
  class="Gallery__big-image"
21
21
  :style="{
22
+ 'background-image': `url(${staticLink(image.large)}`,
22
23
  'background-size': backgroundSize,
23
24
  'background-position': backgroundPosition,
24
25
  'touch-action': zoomEnable ? 'none' : 'auto'
@@ -26,8 +27,7 @@
26
27
  @mousedown="onMouseDown"
27
28
  @mouseenter="onMouseEnter"
28
29
  @mouseleave="onMouseLeave"
29
- @mousemove="onMouseMove"
30
- v-lazy:background-image="staticLink(image.large)">
30
+ @mousemove="onMouseMove">
31
31
  <div
32
32
  v-if="image.print"
33
33
  class="Gallery__big-print">
@@ -65,7 +65,9 @@
65
65
  'Gallery__small-image--active': index === activeIndex
66
66
  }"
67
67
  @click="goToSlideAndChangeColor(index)"
68
- v-lazy:background-image="staticLink(image.small)">
68
+ :style="{
69
+ 'background-image': `url(${staticLink(image.small)}`
70
+ }">
69
71
  <div class="Gallery__small-printed">
70
72
  {{ image.printType ? 'Printed' : (product.prePrint ? product.prePrintText : image.colorName || 'Blank') }}
71
73
  </div>
@@ -175,6 +177,7 @@ export default {
175
177
  if (index > -1) {
176
178
  this.goToSlide(index, true);
177
179
  }
180
+ console.log('filteredImages: ', this.filteredImages);
178
181
  },
179
182
  methods: {
180
183
  ...mapActions('product', ['selectColor']),
package/nuxt.config.js CHANGED
@@ -52,6 +52,7 @@ module.exports = (config, axios, { raygunClient } = {}) => ({
52
52
  { src: '@/node_modules/@lancom/shared/plugins/error-handler', ssr: false },
53
53
  // { src: '@/node_modules/@lancom/shared/plugins/aos', ssr: false },
54
54
  '@/node_modules/@lancom/shared/plugins/aos-animation',
55
+ '@/node_modules/@lancom/shared/plugins/envs',
55
56
  { src: '@/node_modules/@lancom/shared/plugins/vue-recaptcha', ssr: false },
56
57
  // { src: '@/node_modules/@lancom/shared/plugins/vue-tables-2', ssr: false }
57
58
  ],
@@ -68,6 +69,12 @@ module.exports = (config, axios, { raygunClient } = {}) => ({
68
69
  env: {
69
70
  NODE_ENV: config.NODE_ENV || 'development'
70
71
  },
72
+ publicRuntimeConfig: {
73
+ PROD_CDN_URL: process.env.PROD_CDN_URL,
74
+ DEV_CDN_URL: process.env.DEV_CDN_URL,
75
+ PROD_S3_BUCKET: process.env.PROD_S3_BUCKET,
76
+ DEV_S3_BUCKET: process.env.DEV_S3_BUCKET
77
+ },
71
78
  build: {
72
79
  publicPath: '/client/',
73
80
  transpile: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.158",
3
+ "version": "0.0.160",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
@@ -0,0 +1,6 @@
1
+ import Vue from 'vue';
2
+
3
+ export default ({ $config }) => {
4
+ Vue.prototype.$env = $config;
5
+ Vue.$env = $config;
6
+ };
@@ -12,7 +12,7 @@ extend('required', {
12
12
  return `${name} attribute is mandatory`;
13
13
  }
14
14
  });
15
- console.log('ValidationObserver:email', email);
15
+
16
16
  extend('email', {
17
17
  ...email,
18
18
  validate(value) {
@@ -15,7 +15,6 @@ export default () => {
15
15
  await this.loadReCaptcha();
16
16
  await new Promise((resolve, reject) => {
17
17
  interval = setInterval(() => {
18
- console.log('check recaptcha...');
19
18
  if (this.$recaptcha) {
20
19
  clearInterval(interval);
21
20
  resolve()
package/store/cart.js CHANGED
@@ -122,8 +122,9 @@ export const actions = {
122
122
  await api.saveCart(payload, shop._id);
123
123
  commit('setEntities', entities);
124
124
  },
125
- async calculateCartPrice({ state: { suburb, entities, coupon }, commit }, { shop }) {
126
- const payload = generateCalculatePriceData(entities, suburb, null, coupon);
125
+ async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, commit }, { shop }) {
126
+ const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates;
127
+ const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates);
127
128
  try {
128
129
  const response = await api.calculateProductPrice(payload, shop._id);
129
130
  commit('setCartPricing', response);
@@ -209,7 +210,7 @@ export const mutations = {
209
210
  }
210
211
  };
211
212
 
212
- function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon) {
213
+ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon, selectedSuppliersWithRates) {
213
214
  const getSimpleObj = i => i && ({ _id: i._id, name: i.name });
214
215
  return {
215
216
  entities: entities.map(({ _id, guid, prints, simpleProducts, product }) => ({
@@ -241,6 +242,7 @@ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon
241
242
  postcode: suburb && suburb.postcode,
242
243
  address: suburb ? [suburb.locality, suburb.state, suburb.postcode].filter(i => !!i).join(', ') : null,
243
244
  coupon,
244
- suppliersWithRates
245
+ suppliersWithRates,
246
+ selectedSuppliersWithRates
245
247
  };
246
248
  }