@wikala/spmkt 2.13.1 → 2.15.0

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.
package/api/address.js CHANGED
@@ -37,6 +37,14 @@ const Address = {
37
37
  return taddress.filter((i) => i).join(separator)
38
38
  },
39
39
 
40
+ getAddressType(address, allowedTypes=['personal', 'business']) {
41
+ let addressType = address.type
42
+ if(!allowedTypes.includes(address.type)) {
43
+ addressType = allowedTypes[0]
44
+ }
45
+ return addressType
46
+ },
47
+
40
48
  getList() {
41
49
  return request({
42
50
  url: '/addresses/',
@@ -46,7 +54,7 @@ const Address = {
46
54
 
47
55
  edit(addressData) {
48
56
  if (!addressData.type) {
49
- addressData.type = 'customer.shipping'
57
+ addressData.type = 'personal'
50
58
  }
51
59
  if(addressData.type !== 'business') {
52
60
  ['company_name', 'company_tax_id', 'company_business_id'].forEach(
@@ -76,7 +84,7 @@ const Address = {
76
84
 
77
85
  validate(addressData) {
78
86
  if (!addressData.type) {
79
- addressData.type = 'customer.shipping'
87
+ addressData.type = 'personal'
80
88
  }
81
89
  return request({
82
90
  url: '/addresses/validate',
@@ -463,7 +463,7 @@ export default {
463
463
  if(e) {
464
464
  this.addressData.type = 'business'
465
465
  } else {
466
- this.addressData.type = 'customer.shipping'
466
+ this.addressData.type = 'personal'
467
467
  }
468
468
  }
469
469
 
@@ -516,7 +516,7 @@ export default {
516
516
  }
517
517
  }
518
518
 
519
- if(this.addressData.company_name || this.addressData.company_business_id || this.addressData.company_tax_id) {
519
+ if(this.addressData.type === 'business') {
520
520
  this.businessAddress = true
521
521
  this.onChangeIsBusiness(true)
522
522
  }
@@ -88,6 +88,7 @@ import _ from 'underscore'
88
88
  import { mapGetters, mapState, mapActions, mapMutations } from 'vuex'
89
89
 
90
90
  import { Cart } from '../../../api'
91
+ import { Address } from '../../../api'
91
92
 
92
93
  import { createAddress } from '../../Address/address.schema'
93
94
 
@@ -192,22 +193,22 @@ export default {
192
193
 
193
194
  async onDeliveryTypeInput(pl) {
194
195
  //console.log('onDeliveryTypeInput', pl, this.deliveryTypes)
195
-
196
- this.resetDeliveryOptions()
197
-
198
196
  let deliveryMethods = _.findWhere(this.deliveryTypes, { type: pl })['methods']
199
197
  if(deliveryMethods || deliveryMethods.length === 1) {
200
198
  //console.log('setDeliveryMethodId to', deliveryMethods[0]['id'])
201
199
  this.setDeliveryMethodId(deliveryMethods[0]['id'])
202
200
  }
203
201
 
204
- if(pl === 'pickup') {
205
- this.addressValid = true
202
+ if(this.deliveryType === pl) {
203
+ return
206
204
  }
207
205
 
208
- await this.getReservationSlots()
206
+ this.resetDeliveryOptions()
209
207
 
210
- //console.log('checkoutRequestData', JSON.parse(JSON.stringify(this.checkoutRequestData)))
208
+ if(pl === 'pickup') {
209
+ this.addressValid = true
210
+ await this.getReservationSlots()
211
+ }
211
212
  },
212
213
 
213
214
  resetDeliveryOptions() {
@@ -283,13 +284,16 @@ export default {
283
284
  this.scrollToElement('.reservation-slot')
284
285
  return
285
286
  }
287
+
286
288
  let pmreq = {
287
- method: this.deliveryType
289
+ method: this.deliveryType,
290
+ rate_id: '',
291
+ address_type: Address.getAddressType(this.checkoutRequestData.shipping_address),
288
292
  }
289
293
  if (this.deliveryType === 'delivery') {
290
294
  pmreq.rate_id = this.checkoutRequestData.delivery_cost_id
291
295
  }
292
-
296
+
293
297
  this.continueButtonLoading = true
294
298
  await this.getPaymentMethods(pmreq)
295
299
  this.continueButtonLoading = false
@@ -71,7 +71,7 @@ export default {
71
71
  return {
72
72
  addressValid: false,
73
73
  validationErrors: {},
74
- editAutocompleteAddress: false
74
+ editAutocompleteAddress: false,
75
75
  }
76
76
  },
77
77
 
@@ -185,10 +185,12 @@ export default {
185
185
  },
186
186
 
187
187
  setDeliveryAddressUserIdentity() {
188
- this.setDeliveryAddress(createLocalizedVersionAddress(this.initialState, this.$LC, this.countryList))
189
- this.checkoutRequestData.shipping_address.first_name = this.userIdentity.first_name
190
- this.checkoutRequestData.shipping_address.last_name = this.userIdentity.last_name
191
- this.checkoutRequestData.shipping_address.phone = this.userIdentity.phone
188
+ let shipping_address = this.checkoutRequestData.shipping_address;
189
+ let fields = ['first_name', 'last_name', 'phone']
190
+ if(fields.some(f => { return shipping_address[f] !== this.userIdentity[f]})) {
191
+ this.setDeliveryAddress(createLocalizedVersionAddress(this.initialState, this.$LC, this.countryList))
192
+ fields.forEach(f => { this.checkoutRequestData.shipping_address[f] = this.userIdentity[f] })
193
+ }
192
194
  }
193
195
 
194
196
  },
@@ -5,6 +5,7 @@ import _ from 'underscore'
5
5
  import shortid from 'shortid'
6
6
  import GoogleAnalyticsEEC from '../../../utils/google-analytics-eec'
7
7
  import { addressSchema } from '../../Address/address.schema'
8
+ import { Address } from '../../../api'
8
9
 
9
10
  export default {
10
11
  setGuestMode(state, guestMode) {
@@ -65,6 +66,7 @@ export default {
65
66
  state.checkoutRequestData.shipping_address = { ...addressSchema }
66
67
  state.checkoutRequestData.shipping_address_id = ''
67
68
  }
69
+ state.checkoutRequestData.shipping_address.type = Address.getAddressType(state.checkoutRequestData.shipping_address)
68
70
  },
69
71
 
70
72
  setBillingAddress(state, address) {
@@ -77,6 +79,7 @@ export default {
77
79
  state.checkoutRequestData.billing_address = { ...addressSchema }
78
80
  state.checkoutRequestData.billing_address_id = ''
79
81
  }
82
+ state.checkoutRequestData.billing_address.type = Address.getAddressType(state.checkoutRequestData.billing_address)
80
83
  },
81
84
 
82
85
  setDeliveryAddressCoordinates(state, coordinates) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikala/spmkt",
3
- "version": "2.13.1",
3
+ "version": "2.15.0",
4
4
  "private": false,
5
5
  "description": "supermarket",
6
6
  "scripts": {
@@ -30,6 +30,7 @@
30
30
  "@babel/plugin-proposal-optional-chaining": "^7.14.5",
31
31
  "@vue/cli-plugin-babel": "^4.5.13",
32
32
  "@vue/cli-service": "^4.5.13",
33
+ "@vue/runtime-dom": "^3.3.8",
33
34
  "axios": "^0.21.1",
34
35
  "babel-plugin-transform-es2015-modules-commonjs": "^6.26.2",
35
36
  "bootstrap-sass": "^3.4.1",
package/tsconfig.json ADDED
@@ -0,0 +1,8 @@
1
+ {
2
+ "compilerOptions": {
3
+ // ...
4
+ },
5
+ "vueCompilerOptions": {
6
+ "target": 2, // For Vue version <= 2.6.14
7
+ }
8
+ }