@lancom/shared 0.0.377 → 0.0.379

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.
@@ -3,11 +3,18 @@ const phoneValidators = {
3
3
  '+61': /^[0-9]{9,10}$/
4
4
  }
5
5
 
6
+ // export const phone = {
7
+ // validate: (value, params) => {
8
+ // const [code] = params || [];
9
+ // const exp = phoneValidators[code] || /^[0-9-()\s+]+$/;
10
+ // return exp.test(`${value || ''}`);
11
+ // },
12
+ // message: 'Phone number is not valid'
13
+ // };
14
+
6
15
  export const phone = {
7
- validate: (value, params) => {
8
- const [code] = params || [];
9
- const exp = phoneValidators[code] || /^[0-9-()\s+]+$/;
10
- return exp.test(`${value || ''}`);
16
+ validate: value => {
17
+ return /^[0-9-()\s+]+$/.test(`${value}`); // todo add validation for phone number
11
18
  },
12
19
  message: 'Phone number is not valid'
13
20
  };
@@ -15,6 +15,7 @@ export default {
15
15
  ...mapGetters(['shop', 'country', 'currency']),
16
16
  ...mapGetters('auth', ['user']),
17
17
  ...mapGetters('cart', [
18
+ 'needToPickup',
18
19
  'entities',
19
20
  'cartPricing',
20
21
  'simpleProducts',
@@ -27,6 +28,17 @@ export default {
27
28
  'notValidStockQuantities',
28
29
  'notValidPrintsQuantities'
29
30
  ]),
31
+ wantsToPickup: {
32
+ get() {
33
+ return this.needToPickup;
34
+ },
35
+ set(needToPickup) {
36
+ if (needToPickup) {
37
+ this.setSuburb(null);
38
+ }
39
+ this.setNeedToPickup(needToPickup);
40
+ }
41
+ },
30
42
  isNotValidQuantity() {
31
43
  return this.isNotValidProductsQuantity || this.isNotValidStockQuantity || this.isNotValidPrintsQuantity || this.isNotValidPrintsBigSizeQuantity;
32
44
  },
@@ -45,17 +57,18 @@ export default {
45
57
  },
46
58
  watch: {
47
59
  entities() {
48
- this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country });
60
+ this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country, currency: this.currency });
49
61
  }
50
62
  },
51
63
  mounted() {
52
- this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country });
64
+ this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country, currency: this.currency });
53
65
  if (!this.suburb && this.user?.suburb) {
54
66
  this.handleSuburbChange(this.user.suburb);
55
67
  }
56
68
  },
57
69
  methods: {
58
70
  ...mapMutations('cart', [
71
+ 'setNeedToPickup',
59
72
  'setSuburb',
60
73
  'setCoupon'
61
74
  ]),
@@ -63,8 +76,12 @@ export default {
63
76
  'removeSimpleProductsFromCart',
64
77
  'calculateCartPrice'
65
78
  ]),
79
+ recalculatePricing() {
80
+ this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country, currency: this.currency });
81
+ },
66
82
  handleSuburbChange(suburb) {
67
83
  this.setSuburb(suburb);
84
+ this.setNeedToPickup(false);
68
85
  this.calculateCartPrice({ shop: this.shop, country: this.country, currency: this.currency });
69
86
  },
70
87
  handleCouponChange(coupon) {
@@ -36,7 +36,8 @@
36
36
  <checkbox
37
37
  v-model="wantsToPickup"
38
38
  :disabled="hasNotValidProductsPickup"
39
- :dark="true">
39
+ :dark="true"
40
+ @change="recalculatePricing()">
40
41
  <div class="ml-10 Cart__pickup-label">Wants to pickup</div>
41
42
  </checkbox>
42
43
  </div>
@@ -63,7 +64,7 @@
63
64
  <btn
64
65
  :btn-disabled="isNotValidQuantity || cartPricingError || cartPricingCalculating"
65
66
  :btn-block="true"
66
- :to="needToPickup ? `/checkout/order?needToPickup=true` : '/checkout/order'"
67
+ :to="'/checkout/order'"
67
68
  btn-class="green"
68
69
  btn-label="PROCEED TO CHECKOUT">
69
70
  <i
@@ -113,15 +114,7 @@ export default {
113
114
  mixins: [CartMixin],
114
115
  computed: {
115
116
  ...mapGetters(['MESSAGES', 'SETTINGS', 'currency', 'country']),
116
- ...mapGetters('cart', ['isEmpty', 'needToPickup', 'notValidProductsPickup','cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities']),
117
- wantsToPickup: {
118
- get() {
119
- return this.needToPickup;
120
- },
121
- set(needToPickup) {
122
- this.setNeedToPickup(needToPickup);
123
- }
124
- },
117
+ ...mapGetters('cart', ['isEmpty', 'notValidProductsPickup','cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities']),
125
118
  hasNotValidProductsPickup() {
126
119
  return this.notValidProductsPickup.length > 0;
127
120
  },
@@ -148,7 +141,6 @@ export default {
148
141
  }
149
142
  },
150
143
  methods: {
151
- ...mapMutations('cart', ['setNeedToPickup']),
152
144
  loadedPricing() {
153
145
  gtm.viewCart(this.entities, this.cartPricing, this.currency);
154
146
  }
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="OrderBillingInformation__wrapper">
3
3
  <div class="lc_h3 lc_uppercase lc_bold">
4
- Delivery Address
4
+ {{ needToPickup ? 'Contact Info' : 'Delivery Address' }}
5
5
  </div>
6
6
  <div class="OrderBillingInformation__form">
7
7
  <validation-observer
@@ -10,8 +10,11 @@
10
10
  <div class="OrderBillingInformation__content">
11
11
  <address-form
12
12
  :address="order.shippingAddress"
13
+ :only-contact-info="needToPickup"
13
14
  :without-additional-info="true" />
14
- <div class="mt-20 mb-20">
15
+ <div
16
+ v-if="!needToPickup"
17
+ class="mt-20 mb-20">
15
18
  <checkbox
16
19
  v-model="copyToBillingAddress"
17
20
  :dark="true">
@@ -74,11 +77,16 @@ export default {
74
77
  computed: {
75
78
  ...mapGetters(['currency'])
76
79
  },
80
+ mounted() {
81
+ if (this.needToPickup) {
82
+ this.copyToBillingAddress = false;
83
+ }
84
+ },
77
85
  methods: {
78
86
  async submit() {
79
87
  this.isSubmit = true;
80
88
 
81
- const isValid = await this.$refs.form.validate() && !!this.order.shippingAddress.postcode;
89
+ const isValid = await this.$refs.form.validate() && (!!this.order.shippingAddress.postcode || this.needToPickup);
82
90
  if (!isValid) {
83
91
  return;
84
92
  }
@@ -149,11 +149,17 @@ export default {
149
149
  return this.selected?._id ? this.selected : null;
150
150
  },
151
151
  set(option) {
152
-
153
152
  this.updatePostcode(option);
154
153
  }
155
154
  }
156
155
  },
156
+ watch: {
157
+ suburb() {
158
+ if (!this.suburb) {
159
+ this.selected = null;
160
+ }
161
+ }
162
+ },
157
163
  mounted() {
158
164
  if (this.suburb) {
159
165
  const option = this.createOptionFromSuburb(this.suburb);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.377",
3
+ "version": "0.0.379",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
@@ -6,6 +6,8 @@ const SAVE_STATE_MODULES = new Map([
6
6
  ['cart/setId', 'cart.id'],
7
7
  ['cart/clearCart', 'cart.id'],
8
8
  ['cart/setCoupon', 'cart.coupon'],
9
+ ['cart/setNeedToPickup', 'cart.needToPickup'],
10
+ ['cart/setSuburb', 'cart.suburb'],
9
11
  ['cart/clearCart', 'cart.coupon']
10
12
  ]);
11
13
 
package/store/index.js CHANGED
@@ -53,7 +53,7 @@ export const getters = {
53
53
  };
54
54
 
55
55
  export const actions = {
56
- async nuxtServerInit({ commit }, { req, query }) {
56
+ async nuxtServerInit({ commit }, { req }) {
57
57
  const shop = await api.fetchShopByUrl(process.env.HOST_NAME);
58
58
  const menus = await api.fetchMenus(shop._id);
59
59
  commit('setMenus', menus);
@@ -98,10 +98,6 @@ export const actions = {
98
98
  }
99
99
  }
100
100
  } catch (e) {}
101
-
102
- if (query?.needToPickup === 'true') {
103
- commit('cart/setNeedToPickup', true);
104
- }
105
101
  },
106
102
  async loadState({ dispatch, commit, state: { shop, currency, country, notificationBar } }, query) {
107
103
  const state = await loadState();
@@ -124,9 +120,8 @@ export const actions = {
124
120
  dispatch('cart/calculateCartPrice', { shop, country });
125
121
  }
126
122
  }
127
- if (query.gclid || state?.googleClickId) {
128
- commit('setGoogleClickId', query.gclid || state?.googleClickId);
129
- }
123
+ commit('setGoogleClickId', query.gclid || state?.googleClickId || null);
124
+
130
125
  const closedNotification = localStorage.getItem(CLOSED_NOTIFICATION);
131
126
  if (notificationBar?.text === closedNotification) {
132
127
  commit('setNotificationBar', { ...notificationBar, enabled: false });