@lancom/shared 0.0.151 → 0.0.153

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.
@@ -4,6 +4,7 @@ const Cookie = process.client ? require('js-cookie') : undefined;
4
4
  const axiosApiInstance = axios.create();
5
5
 
6
6
  if (process.client) {
7
+ console.log('error: ');
7
8
  axiosApiInstance.interceptors.request.use(
8
9
  config => {
9
10
  const auth = Cookie.get('auth');
@@ -13,8 +14,18 @@ if (process.client) {
13
14
  return config;
14
15
  },
15
16
  error => {
16
- Promise.reject(error);
17
+ return Promise.reject(error);
17
18
  });
19
+ axiosApiInstance.interceptors.response.use(
20
+ response => response,
21
+ error => {
22
+ if (error.response.status === 401) {
23
+ Cookie.remove('auth');
24
+ window.location ='/';
25
+ return;
26
+ }
27
+ return Promise.reject(error);
28
+ });
18
29
  }
19
30
 
20
31
  const API_URL = process.client ? process.env.API_URL : process.env.LOCAL_API_URL;
@@ -82,6 +82,8 @@ export const date = d => dayjs(d).format('ddd, MMM D, YYYY h:mm A');
82
82
 
83
83
  export const shortDate = d => dayjs(d).format('DD/MM/YYYY');
84
84
 
85
+ export const shortUtcDate = d => dayjs(d).utc().format('DD/MM');
86
+
85
87
  export const sydneyTime = d => dayjs(d).utc().utcOffset(10).format('MMM D, YYYY h:mm A');
86
88
 
87
89
  export const priceInRange = (prices, amount) => ((prices || []).find(({ min, max }) => min <= amount && (!max || max >= amount)) || { price: 0 }).price;
@@ -1,3 +1,5 @@
1
+ import { generateGUID } from '@lancom/shared/assets/js/utils/guid';
2
+
1
3
  export function getPrintAreasSizes(printAreas, side) {
2
4
  return printAreas
3
5
  .filter(printArea => !side || printArea.side === side)
@@ -38,6 +40,7 @@ export function getPrintsFromLayers(layers, product) {
38
40
  const { setupCost, printCost, freeSetupOver } = getPrintTypeSizePricing(layerPrintType, printSize) || {};
39
41
  const getSimpleObj = i => i && ({ _id: i._id, name: i.name });
40
42
  const data = {
43
+ guid: layer.printGuid || generateGUID(),
41
44
  printArea: getSimpleObj(layerPrintArea),
42
45
  printType: getSimpleObj(layerPrintType),
43
46
  printSize: getSimpleObj(layerPrintSize),
@@ -48,8 +51,10 @@ export function getPrintsFromLayers(layers, product) {
48
51
  layers: [generatePrintLayer(layer)]
49
52
  };
50
53
  prints.set(printArea, data);
54
+ layer.printGuid = data.guid;
51
55
  } else {
52
56
  const print = prints.get(printArea);
57
+ layer.printGuid = print.guid;
53
58
  print.layers.push(generatePrintLayer(layer));
54
59
  prints.set(printArea, print);
55
60
  }
@@ -223,6 +223,7 @@ $types: delivery, general, other, printing, garments;
223
223
  line-height: 25px;
224
224
  letter-spacing: 0.02em;
225
225
  color: $dark_blue;
226
+ padding-right: 40px;
226
227
  }
227
228
  &-body {
228
229
  padding: 6px 30px 24px 30px;
@@ -3,8 +3,7 @@
3
3
  <div class="ProductPrintsPriceInfo__toggle-gst">
4
4
  <checkbox
5
5
  v-model="inclGST"
6
- :dark="true"
7
- @change="onChangeInclGST">
6
+ :dark="true">
8
7
  <div class="ml-5">Inc. GST</div>
9
8
  </checkbox>
10
9
  </div>
@@ -46,7 +45,7 @@
46
45
  </template>
47
46
 
48
47
  <script>
49
- import { mapActions, mapGetters } from 'vuex';
48
+ import { mapActions, mapGetters, mapMutations } from 'vuex';
50
49
  import Tabs from '@lancom/shared/components/common/tabs';
51
50
  import { price } from '@lancom/shared/assets/js/utils/filters';
52
51
  import { PRINT_TYPES, PRINT_TYPES_LIST } from '@lancom/shared/assets/js/constants/print-type';
@@ -68,8 +67,7 @@ export default {
68
67
  },
69
68
  data() {
70
69
  return {
71
- inclGST: false,
72
- inclGSTFinal: false,
70
+ inclGSTFinal: true,
73
71
  inclGSTSpinner: false,
74
72
  inclGSTSpinnerTimer: null,
75
73
  orderPrintTypes: PRINT_TYPES_LIST,
@@ -91,6 +89,7 @@ export default {
91
89
  },
92
90
  computed: {
93
91
  ...mapGetters(['shop']),
92
+ ...mapGetters('product', ['priceIncludeGST']),
94
93
  ...mapGetters(['helpMessages']),
95
94
  hasPrintSurcharge() {
96
95
  return this.product.printSurcharge > 0;
@@ -111,6 +110,19 @@ export default {
111
110
  currentPrintTypeMessage() {
112
111
  const { message } = this.helpMessages[this.selectedTab] || {};
113
112
  return message || '';
113
+ },
114
+ inclGST: {
115
+ get() {
116
+ return this.priceIncludeGST;
117
+ },
118
+ set(value) {
119
+ this.setPriceIncludeGST(value);
120
+ }
121
+ }
122
+ },
123
+ watch: {
124
+ inclGST() {
125
+ this.onChangeInclGST();
114
126
  }
115
127
  },
116
128
  mounted() {
@@ -125,6 +137,7 @@ export default {
125
137
  },
126
138
  methods: {
127
139
  ...mapActions(['loadHelpMessages']),
140
+ ...mapMutations('product', ['setPriceIncludeGST']),
128
141
  onChangeInclGST() {
129
142
  clearTimeout(this.inclGSTSpinnerTimer);
130
143
  this.inclGSTSpinner = true;
@@ -29,11 +29,11 @@
29
29
  }
30
30
  }
31
31
  &-all {
32
+ border-top: 1px solid $gray_main;
32
33
  padding: 10px;
33
34
  text-align: center;
34
35
  display: block;
35
36
  background-color: $white;
36
- border-bottom: 1px solid $gray_main;
37
37
  &:hover {
38
38
  background-color: $black;
39
39
  color: $white;
@@ -27,13 +27,6 @@
27
27
  <spinner v-if="searching" />
28
28
  </div>
29
29
  <div v-if="hasProducts">
30
- <products-autocomplete-item
31
- v-for="product of products"
32
- :key="product._id"
33
- :to-editor="false"
34
- :product="product"
35
- class="ProductsAutocomplete__result-item"
36
- @select="$emit('select', product)" />
37
30
  <div class="ProductsAutocomplete__result-item">
38
31
  <nuxt-link
39
32
  class="ProductsAutocomplete__result-item-all"
@@ -41,6 +34,13 @@
41
34
  click to see all results
42
35
  </nuxt-link>
43
36
  </div>
37
+ <products-autocomplete-item
38
+ v-for="product of products"
39
+ :key="product._id"
40
+ :to-editor="false"
41
+ :product="product"
42
+ class="ProductsAutocomplete__result-item"
43
+ @select="$emit('select', product)" />
44
44
  </div>
45
45
  </div>
46
46
  </div>
@@ -57,4 +57,11 @@
57
57
  margin: 1px 4px;
58
58
  }
59
59
  }
60
+ &__toggle-list {
61
+ margin-top: 5px;
62
+ margin-right: 10px;
63
+ font-size: 11px;
64
+ cursor: pointer;
65
+ text-align: right;
66
+ }
60
67
  }
@@ -21,7 +21,7 @@
21
21
  </div>
22
22
  <div class="ProductsColors__items">
23
23
  <products-link
24
- v-for="color in colors"
24
+ v-for="color in visibleColors"
25
25
  :key="color._id"
26
26
  v-tooltip="color.name"
27
27
  :color="color.alias">
@@ -37,6 +37,12 @@
37
37
  </div>
38
38
  </products-link>
39
39
  </div>
40
+ <div
41
+ v-if="shortListColorsLimit < colorsCount"
42
+ @click="toggleDisplayAllColors()"
43
+ class="ProductsColors__toggle-list">
44
+ {{ displayAllColors ? 'Hide all colours' : 'Show all colours' }}
45
+ </div>
40
46
  </toggle-content>
41
47
  </div>
42
48
  </template>
@@ -56,14 +62,22 @@ export default {
56
62
  },
57
63
  data() {
58
64
  return {
59
- canLoadImages: false
65
+ canLoadImages: false,
66
+ displayAllColors: false,
67
+ shortListColorsLimit: 15
60
68
  };
61
69
  },
62
70
  computed: {
63
71
  ...mapGetters('products', ['colors']),
72
+ colorsCount() {
73
+ return this.colors.length;
74
+ },
64
75
  selectedColors() {
65
76
  const colors = (this.$route.query.colors || '').split(',');
66
77
  return this.colors.filter(color => colors.includes(color.alias));
78
+ },
79
+ visibleColors() {
80
+ return this.displayAllColors ? this.colors : this.colors.slice(0, this.shortListColorsLimit);
67
81
  }
68
82
  },
69
83
  mounted() {
@@ -74,6 +88,9 @@ export default {
74
88
  methods: {
75
89
  isSelectedColor(color) {
76
90
  return this.selectedColors.some(c => c._id === color._id);
91
+ },
92
+ toggleDisplayAllColors() {
93
+ this.displayAllColors = !this.displayAllColors;
77
94
  }
78
95
  }
79
96
  };
@@ -29,7 +29,7 @@
29
29
  v-slot="{ errors }"
30
30
  tag="div"
31
31
  name="Email"
32
- rules="required"
32
+ rules="required|email"
33
33
  class="form-row">
34
34
  <input
35
35
  :id="'email' + uniqueKey"
package/nuxt.config.js CHANGED
@@ -56,6 +56,7 @@ module.exports = (config, axios, { raygunClient } = {}) => ({
56
56
  // { src: '@/node_modules/@lancom/shared/plugins/vue-tables-2', ssr: false }
57
57
  ],
58
58
  modules: [
59
+ 'nuxt-helmet',
59
60
  '@nuxtjs/axios',
60
61
  '@nuxtjs/dotenv',
61
62
  '@nuxtjs/sitemap',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.151",
3
+ "version": "0.0.153",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
@@ -12,7 +12,26 @@ extend('required', {
12
12
  return `${name} attribute is mandatory`;
13
13
  }
14
14
  });
15
- extend('email', email);
15
+ console.log('ValidationObserver:email', email);
16
+ extend('email', {
17
+ ...email,
18
+ validate(value) {
19
+ if (email.validate(value)) {
20
+ const auDomain = value.match(/\.co[a-z]+\.au$/i);
21
+ const comDomain = value.match(/\.co[a-z]+$/i);
22
+ if (auDomain && auDomain[0]) {
23
+ return auDomain[0] === '.com.au';
24
+ } else if (comDomain && comDomain[0]) {
25
+ return comDomain[0] === '.com';
26
+ }
27
+ return true;
28
+ }
29
+ return false;
30
+ }
31
+ // message(name) {
32
+ // return `${name} attribute is mandatory`;
33
+ // }
34
+ });
16
35
  extend('max', max);
17
36
  extend('float', float);
18
37
  extend('min_value', minValue);
package/store/cart.js CHANGED
@@ -66,9 +66,12 @@ export const getters = {
66
66
  export const actions = {
67
67
  async addToCart({ state, commit }, { entities, shop, pricing }) {
68
68
  const addingEntities = [...entities];
69
- const withoutPrints = e => (e.prints || []).length === 0;
69
+ const isSamePrints = (e, e2) => {
70
+ const samePrints = (e.prints || []).filter(p => (e2.prints || []).some(p2 => p2.guid === p.guid));
71
+ return (e.prints || []).length === samePrints.length;
72
+ };
70
73
  entities = entities.map(e => {
71
- const entitiy = withoutPrints(e) && state.entities.find(e2 => withoutPrints(e2) && e2?.product?._id === e?.product?._id);
74
+ const entitiy = state.entities.find(e2 => isSamePrints(e, e2) && e2?.product?._id === e?.product?._id);
72
75
  if (entitiy) {
73
76
  e.simpleProducts.forEach(sp => {
74
77
  const simpleProduct = entitiy.simpleProducts.find(sp2 => sp2.SKU === sp.SKU);
package/store/product.js CHANGED
@@ -9,6 +9,7 @@ import { getProductsForCalculatePricing } from '@lancom/shared/assets/js/utils/p
9
9
  import { sortByName } from '../assets/js/utils/filters';
10
10
 
11
11
  export const state = () => ({
12
+ priceIncludeGST: true,
12
13
  product: null,
13
14
  preSetPrint: null,
14
15
  loadError: null,
@@ -124,6 +125,7 @@ export const getters = {
124
125
  return [...imagesGroups.values()].reduce((images, group) => [...images, ...group], []);
125
126
  },
126
127
  editableSide: ({ editableSide }) => editableSide,
128
+ priceIncludeGST: ({ priceIncludeGST }) => priceIncludeGST,
127
129
  hasUnprintedPrice: ({ product }) => product.minUnprintedPrice || product.maxUnprintedPrice
128
130
  };
129
131
 
@@ -226,6 +228,9 @@ export const mutations = {
226
228
  setProduct(state, product) {
227
229
  state.product = product;
228
230
  },
231
+ setPriceIncludeGST(state, priceIncludeGST) {
232
+ state.priceIncludeGST = priceIncludeGST;
233
+ },
229
234
  setLoadError(state, error) {
230
235
  state.loadError = error;
231
236
  },