@lancom/shared 0.0.152 → 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;
@@ -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>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.152",
3
+ "version": "0.0.153",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
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
  },