@ecomplus/storefront-components 1.0.0-beta.17 → 1.0.0-beta.171

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.
Files changed (125) hide show
  1. package/CHANGELOG.md +1224 -131
  2. package/README.md +9 -4
  3. package/all.js +3 -1
  4. package/dist/1.storefront-components.min.js +2 -0
  5. package/dist/1.storefront-components.min.js.map +1 -0
  6. package/dist/2.storefront-components.min.js +5 -0
  7. package/dist/2.storefront-components.min.js.map +1 -0
  8. package/dist/3.storefront-components.min.js +5 -0
  9. package/dist/3.storefront-components.min.js.map +1 -0
  10. package/dist/storefront-components.min.js +33 -12
  11. package/dist/storefront-components.min.js.map +1 -1
  12. package/package.json +19 -14
  13. package/src/APagination.vue +2 -0
  14. package/src/AShare.vue +2 -0
  15. package/src/AccountAddresses.vue +3 -0
  16. package/src/AccountForm.vue +3 -0
  17. package/src/AccountPoints.vue +3 -0
  18. package/src/BuyTogether.vue +3 -0
  19. package/src/EarnPointsProgress.vue +3 -0
  20. package/src/ItemCustomizations.vue +2 -0
  21. package/src/KitProductVariations.vue +3 -0
  22. package/src/PointsApplier.vue +2 -0
  23. package/src/ProductQuickview.vue +3 -0
  24. package/src/QuantitySelector.vue +3 -0
  25. package/src/RecommendedItems.vue +3 -0
  26. package/src/ShippingLine.vue +1 -0
  27. package/src/TheCart.vue +3 -0
  28. package/src/html/APagination.html +90 -0
  29. package/src/html/APrices.html +24 -4
  30. package/src/html/AShare.html +31 -0
  31. package/src/html/AccountAddresses.html +90 -0
  32. package/src/html/AccountForm.html +269 -0
  33. package/src/html/AccountPoints.html +39 -0
  34. package/src/html/AddressForm.html +9 -7
  35. package/src/html/BuyTogether.html +60 -0
  36. package/src/html/CartItem.html +86 -38
  37. package/src/html/CartQuickview.html +28 -5
  38. package/src/html/DiscountApplier.html +2 -2
  39. package/src/html/EarnPointsProgress.html +28 -0
  40. package/src/html/InputDate.html +1 -1
  41. package/src/html/InputDocNumber.html +1 -0
  42. package/src/html/InputPhone.html +1 -1
  43. package/src/html/InstantSearch.html +3 -3
  44. package/src/html/ItemCustomizations.html +14 -0
  45. package/src/html/KitProductVariations.html +92 -0
  46. package/src/html/LoginBlock.html +34 -32
  47. package/src/html/LoginModal.html +9 -4
  48. package/src/html/PaymentOption.html +7 -5
  49. package/src/html/PointsApplier.html +26 -0
  50. package/src/html/ProductCard.html +56 -8
  51. package/src/html/ProductGallery.html +21 -3
  52. package/src/html/ProductQuickview.html +64 -0
  53. package/src/html/ProductVariations.html +30 -3
  54. package/src/html/QuantitySelector.html +85 -0
  55. package/src/html/RecommendedItems.html +48 -0
  56. package/src/html/SearchEngine.html +100 -24
  57. package/src/html/ShippingCalculator.html +53 -3
  58. package/src/html/ShippingLine.html +5 -2
  59. package/src/html/TheAccount.html +43 -9
  60. package/src/html/TheCart.html +156 -0
  61. package/src/html/TheProduct.html +416 -138
  62. package/src/js/APagination.js +74 -0
  63. package/src/js/APicture.js +27 -7
  64. package/src/js/APrices.js +80 -41
  65. package/src/js/AShare.js +83 -0
  66. package/src/js/AccountAddresses.js +192 -0
  67. package/src/js/AccountForm.js +312 -0
  68. package/src/js/AccountPoints.js +63 -0
  69. package/src/js/AddressForm.js +80 -35
  70. package/src/js/BuyTogether.js +246 -0
  71. package/src/js/CartItem.js +67 -14
  72. package/src/js/CartQuickview.js +21 -2
  73. package/src/js/DiscountApplier.js +132 -42
  74. package/src/js/EarnPointsProgress.js +77 -0
  75. package/src/js/InputDate.js +8 -8
  76. package/src/js/InputDocNumber.js +20 -0
  77. package/src/js/ItemCustomizations.js +10 -0
  78. package/src/js/KitProductVariations.js +218 -0
  79. package/src/js/LoginBlock.js +14 -2
  80. package/src/js/LoginModal.js +17 -4
  81. package/src/js/PaymentOption.js +28 -1
  82. package/src/js/PointsApplier.js +110 -0
  83. package/src/js/ProductCard.js +97 -11
  84. package/src/js/ProductGallery.js +32 -12
  85. package/src/js/ProductQuickview.js +72 -0
  86. package/src/js/ProductVariations.js +76 -19
  87. package/src/js/QuantitySelector.js +175 -0
  88. package/src/js/RecommendedItems.js +178 -0
  89. package/src/js/SearchEngine.js +185 -55
  90. package/src/js/ShippingCalculator.js +157 -33
  91. package/src/js/ShippingLine.js +21 -5
  92. package/src/js/TheAccount.js +87 -6
  93. package/src/js/TheCart.js +146 -0
  94. package/src/js/TheProduct.js +387 -43
  95. package/src/js/helpers/add-idle-callback.js +7 -0
  96. package/src/js/helpers/check-form-validity.js +3 -0
  97. package/src/js/helpers/favorite-products.js +24 -0
  98. package/src/js/helpers/scroll-to-element.js +10 -0
  99. package/src/js/helpers/sort-apps.js +14 -0
  100. package/src/js/helpers/wait-storefront-info.js +21 -0
  101. package/src/scss/APicture.scss +2 -0
  102. package/src/scss/APrices.scss +13 -1
  103. package/src/scss/AccountAddresses.scss +27 -0
  104. package/src/scss/AccountForm.scss +5 -0
  105. package/src/scss/AccountPoints.scss +17 -0
  106. package/src/scss/BuyTogether.scss +38 -0
  107. package/src/scss/CartItem.scss +17 -1
  108. package/src/scss/EarnPointsProgress.scss +6 -0
  109. package/src/scss/InstantSearch.scss +1 -0
  110. package/src/scss/KitProductVariations.scss +72 -0
  111. package/src/scss/LoginBlock.scss +5 -0
  112. package/src/scss/PaymentOption.scss +10 -1
  113. package/src/scss/ProductCard.scss +66 -28
  114. package/src/scss/ProductGallery.scss +4 -2
  115. package/src/scss/ProductQuickview.scss +36 -0
  116. package/src/scss/ProductVariations.scss +20 -4
  117. package/src/scss/QuantitySelector.scss +39 -0
  118. package/src/scss/RecommendedItems.scss +28 -0
  119. package/src/scss/SearchEngine.scss +9 -5
  120. package/src/scss/ShippingCalculator.scss +30 -1
  121. package/src/scss/ShippingLine.scss +20 -0
  122. package/src/scss/TheAccount.scss +4 -0
  123. package/src/scss/TheCart.scss +54 -0
  124. package/src/scss/TheProduct.scss +146 -1
  125. package/webpack.config.js +20 -6
@@ -1,6 +1,10 @@
1
1
  import {
2
2
  i19days,
3
+ i19free,
3
4
  i19freeShipping,
5
+ i19pickUpToday,
6
+ i19receiveToday,
7
+ i19untilTomorrow,
4
8
  i19upTo,
5
9
  i19workingDays
6
10
  } from '@ecomplus/i18n'
@@ -17,6 +21,10 @@ export default {
17
21
  shippingLine: {
18
22
  type: Object,
19
23
  required: true
24
+ },
25
+ productionDeadline: {
26
+ type: Number,
27
+ default: 0
20
28
  }
21
29
  },
22
30
 
@@ -29,17 +37,25 @@ export default {
29
37
  if (shipping.delivery_time) {
30
38
  days += shipping.delivery_time.days
31
39
  }
32
- return `${i18n(i19upTo)} ${days} ${i18n(isWorkingDays ? i19workingDays : i19days)}`
40
+ days += this.productionDeadline
41
+ if (days > 1) {
42
+ return `${i18n(i19upTo)} ${days} ` +
43
+ i18n(isWorkingDays ? i19workingDays : i19days).toLowerCase()
44
+ }
45
+ return i18n(days === 1
46
+ ? i19untilTomorrow
47
+ : shipping.pick_up ? i19pickUpToday : i19receiveToday)
33
48
  },
34
49
 
35
50
  freightValueStr () {
36
- const freight = typeof this.shippingLine.total_price === 'number'
37
- ? this.shippingLine.total_price
38
- : this.shippingLine.price
51
+ const { shippingLine } = this
52
+ const freight = typeof shippingLine.total_price === 'number'
53
+ ? shippingLine.total_price
54
+ : shippingLine.price
39
55
  if (freight) {
40
56
  return formatMoney(freight)
41
57
  } else {
42
- return i18n(i19freeShipping)
58
+ return i18n(shippingLine.pick_up ? i19free : i19freeShipping)
43
59
  }
44
60
  }
45
61
  }
@@ -1,10 +1,13 @@
1
1
  import {
2
2
  i19addresses,
3
+ i19favorites,
3
4
  i19hello,
4
5
  i19isNotYou,
5
6
  i19logout,
7
+ i19noSavedFavoritesMsg,
6
8
  i19orders,
7
- i19registration
9
+ i19registration,
10
+ i19subscriptions
8
11
  } from '@ecomplus/i18n'
9
12
 
10
13
  import {
@@ -14,12 +17,14 @@ import {
14
17
 
15
18
  import ecomPassport from '@ecomplus/passport-client'
16
19
  import LoginBlock from '../LoginBlock.vue'
20
+ import RecommendedItems from '../RecommendedItems.vue'
17
21
 
18
22
  export default {
19
23
  name: 'TheAccount',
20
24
 
21
25
  components: {
22
- LoginBlock
26
+ LoginBlock,
27
+ RecommendedItems
23
28
  },
24
29
 
25
30
  props: {
@@ -29,7 +34,12 @@ export default {
29
34
  return {}
30
35
  }
31
36
  },
32
- isOrdersList: Boolean,
37
+ currentTab: {
38
+ type: String,
39
+ validator: function (value) {
40
+ return ['orders', 'favorites', 'subscriptions', 'points', 'account'].includes(value)
41
+ }
42
+ },
33
43
  ecomPassport: {
34
44
  type: Object,
35
45
  default () {
@@ -38,20 +48,30 @@ export default {
38
48
  }
39
49
  },
40
50
 
51
+ data () {
52
+ return {
53
+ favoriteIds: [],
54
+ navTabs: []
55
+ }
56
+ },
57
+
41
58
  computed: {
42
59
  i19addresses: () => i18n(i19addresses),
60
+ i19favorites: () => i18n(i19favorites),
43
61
  i19hello: () => i18n(i19hello),
44
62
  i19isNotYou: () => i18n(i19isNotYou),
45
63
  i19logout: () => i18n(i19logout),
64
+ i19noSavedFavoritesMsg: () => i18n(i19noSavedFavoritesMsg),
46
65
  i19orders: () => i18n(i19orders),
66
+ i19subscriptions: () => i18n(i19subscriptions),
47
67
  i19registration: () => i18n(i19registration),
48
68
 
49
69
  activeTab: {
50
70
  get () {
51
- return this.isOrdersList ? 1 : 0
71
+ return this.currentTab || 'account'
52
72
  },
53
- set (tabIndex) {
54
- this.$emit('update:is-orders-list', tabIndex === 1)
73
+ set (tab) {
74
+ this.$emit('update:current-tab', tab)
55
75
  }
56
76
  },
57
77
 
@@ -70,6 +90,27 @@ export default {
70
90
  },
71
91
 
72
92
  methods: {
93
+ hasTab (tabValue) {
94
+ return this.navTabs.some(tab => tab.value === tabValue)
95
+ },
96
+
97
+ insertSubscriptionTab () {
98
+ const hasSubscriptions = this.hasTab('subscriptions')
99
+ if (this.ecomPassport.checkAuthorization() && !hasSubscriptions) {
100
+ this.ecomPassport.requestApi('/orders.json?transactions.type=recurrence&limit=1&fields=_id')
101
+ .then(({ data }) => {
102
+ const { result } = data
103
+ if (result.length) {
104
+ this.navTabs.push({
105
+ label: this.i19subscriptions,
106
+ value: 'subscriptions'
107
+ })
108
+ }
109
+ })
110
+ .catch(console.error)
111
+ }
112
+ },
113
+
73
114
  login (ecomPassport) {
74
115
  if (ecomPassport.checkAuthorization()) {
75
116
  this.localCustomer = ecomPassport.getCustomer()
@@ -83,5 +124,45 @@ export default {
83
124
  this.$emit('logout')
84
125
  }
85
126
  }
127
+ },
128
+
129
+ watch: {
130
+ customer: {
131
+ handler (customer) {
132
+ const hasPoints = this.hasTab('points')
133
+ if (Array.isArray(customer.loyalty_points_entries) && customer.loyalty_points_entries.length && !hasPoints) {
134
+ this.navTabs.push({
135
+ label: 'Cashback',
136
+ value: 'points'
137
+ })
138
+ }
139
+ },
140
+ immediate: true,
141
+ deep: true
142
+ }
143
+ },
144
+
145
+ created () {
146
+ this.navTabs = [
147
+ {
148
+ label: this.i19registration,
149
+ value: 'account'
150
+ },
151
+ {
152
+ label: this.i19orders,
153
+ value: 'orders'
154
+ },
155
+ {
156
+ label: this.i19favorites,
157
+ value: 'favorites'
158
+ }
159
+ ]
160
+ const { favorites } = this.ecomPassport.getCustomer()
161
+ this.favoriteIds = favorites || []
162
+ this.insertSubscriptionTab()
163
+ this.ecomPassport.on('login', this.insertSubscriptionTab)
164
+ this.$once('hook:beforeDestroy', () => {
165
+ this.ecomPassport.off('login', this.insertSubscriptionTab)
166
+ })
86
167
  }
87
168
  }
@@ -0,0 +1,146 @@
1
+ import {
2
+ i19checkout,
3
+ i19continueShopping,
4
+ i19discount,
5
+ i19emptyCart
6
+ } from '@ecomplus/i18n'
7
+
8
+ import {
9
+ i18n,
10
+ formatMoney
11
+ } from '@ecomplus/utils'
12
+
13
+ import ecomCart from '@ecomplus/shopping-cart'
14
+ import APrices from './../APrices.vue'
15
+ import CartItem from './../CartItem.vue'
16
+ import DiscountApplier from './../DiscountApplier.vue'
17
+ import ShippingCalculator from './../ShippingCalculator.vue'
18
+ import EarnPointsProgress from './../EarnPointsProgress.vue'
19
+ import RecommendedItems from './../RecommendedItems.vue'
20
+
21
+ export default {
22
+ name: 'TheCart',
23
+
24
+ components: {
25
+ APrices,
26
+ CartItem,
27
+ DiscountApplier,
28
+ ShippingCalculator,
29
+ EarnPointsProgress,
30
+ RecommendedItems
31
+ },
32
+
33
+ props: {
34
+ amount: {
35
+ type: Object,
36
+ default () {
37
+ return {}
38
+ }
39
+ },
40
+ checkoutUrl: {
41
+ type: String,
42
+ default: '/app/#/checkout'
43
+ },
44
+ zipCode: String,
45
+ discountCoupon: String,
46
+ modulesPayload: Object,
47
+ ecomCart: {
48
+ type: Object,
49
+ default () {
50
+ return ecomCart
51
+ }
52
+ }
53
+ },
54
+
55
+ data () {
56
+ return {
57
+ localZipCode: this.zipCode,
58
+ canApplyDiscount: false,
59
+ isCouponApplied: false
60
+ }
61
+ },
62
+
63
+ computed: {
64
+ i19checkout: () => i18n(i19checkout),
65
+ i19continueShopping: () => i18n(i19continueShopping),
66
+ i19discount: () => i18n(i19discount),
67
+ i19emptyCart: () => i18n(i19emptyCart),
68
+
69
+ cart () {
70
+ return this.ecomCart.data
71
+ },
72
+
73
+ isValidCart () {
74
+ return this.ecomCart.data.items.find(({ quantity }) => quantity)
75
+ },
76
+
77
+ localDiscountCoupon: {
78
+ get () {
79
+ return this.discountCoupon
80
+ },
81
+ set (couponCode) {
82
+ this.$emit('update:discount-coupon', couponCode)
83
+ }
84
+ }
85
+ },
86
+
87
+ methods: {
88
+ formatMoney,
89
+
90
+ selectShippingService (service) {
91
+ this.$emit('select-shipping', service)
92
+ this.$nextTick(() => {
93
+ this.canApplyDiscount = true
94
+ })
95
+ },
96
+
97
+ setDiscountRule (discountRule) {
98
+ this.$emit('set-discount-rule', discountRule)
99
+ this.$nextTick(() => {
100
+ this.isCouponApplied = Boolean(this.discountCoupon && this.amount.discount)
101
+ })
102
+ }
103
+ },
104
+
105
+ watch: {
106
+ localZipCode (zipCode) {
107
+ this.$emit('update:zip-code', zipCode)
108
+ },
109
+
110
+ canApplyDiscount (canApplyDiscount) {
111
+ if (!canApplyDiscount) {
112
+ this.isCouponApplied = false
113
+ }
114
+ }
115
+ },
116
+
117
+ mounted () {
118
+ this.$nextTick(() => {
119
+ this.canApplyDiscount = !this.localZipCode
120
+ })
121
+ const { ecomCart } = this
122
+ const getNumItems = () => ecomCart.data.items.reduce((numItems, { flags, quantity }) => {
123
+ if (!flags || !flags.includes('freebie')) {
124
+ numItems += quantity
125
+ }
126
+ return numItems
127
+ }, 0)
128
+ let oldNumItems = getNumItems()
129
+ const cartWatcher = () => {
130
+ this.canApplyDiscount = !this.localZipCode
131
+ const numItems = getNumItems()
132
+ if (oldNumItems !== numItems) {
133
+ ecomCart.data.items.forEach(({ _id, quantity, flags }) => {
134
+ if (Array.isArray(flags) && flags.includes('freebie') && quantity === 1) {
135
+ ecomCart.removeItem(_id)
136
+ }
137
+ })
138
+ oldNumItems = numItems
139
+ }
140
+ }
141
+ ecomCart.on('change', cartWatcher)
142
+ this.$once('hook:beforeDestroy', () => {
143
+ ecomCart.off('change', cartWatcher)
144
+ })
145
+ }
146
+ }