@wikala/spmkt 2.30.0 → 2.31.1

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.
@@ -5,6 +5,17 @@
5
5
  <input @keyup.enter="applyCoupon" v-model="couponCode" class="input" type="text" name="coupon_code" :placeholder="$t('cart.enterCouponPlaceholder')" />
6
6
  <button name="enter_coupon" @click="applyCoupon" class="button is-small" :class="{ 'is-loading': acLoading }">{{ $t('cart.applyCoupon') }}</button>
7
7
  </div>
8
+ <!-- Coupon the shop offers to this customer, passed by the server in initial state as offered_coupon -->
9
+ <div v-if="offeredCoupon" class="pc-offer" data-test="offered-coupon">
10
+ <div>
11
+ {{ $t('cart.offeredCoupon') }}: <strong class="pc-offer-code">{{ offeredCoupon.code }}</strong>
12
+ <button v-if="!offeredCouponApplied" type="button" name="apply_offered_coupon" class="button is-small pc-offer-apply" @click="applyCode(offeredCoupon.code)">{{ $t('cart.applyOfferedCoupon') }}</button>
13
+ </div>
14
+ <div class="pc-offer-details">
15
+ {{ offeredCoupon.description }}
16
+ <template v-if="offeredCoupon.expires_at">{{ $t('cart.couponValidUntil', { date: offeredCoupon.expires_at }) }}</template>
17
+ </div>
18
+ </div>
8
19
  <div v-if="cart.discount">
9
20
  <div class="applied-discounts has-text-weight-bold">
10
21
  <div class="has-text-success">{{ $t('cart.discountApplied') }} [{{ cart.coupon_code }}]</div>
@@ -34,6 +45,7 @@
34
45
  <script>
35
46
  import { mapState, mapMutations } from 'vuex'
36
47
  import { formatMoney } from '../../utils/filters'
48
+ import config from '../../config'
37
49
 
38
50
  import { request } from '../../api'
39
51
 
@@ -42,17 +54,27 @@ export default {
42
54
  data() {
43
55
  return {
44
56
  acLoading: false,
45
- couponCode: ''
57
+ couponCode: '',
58
+ offeredCoupon: config.INITIAL_STATE?.offered_coupon || null
46
59
  }
47
60
  },
48
61
  computed: {
49
- ...mapState(['cart'])
62
+ ...mapState(['cart']),
63
+
64
+ offeredCouponApplied() {
65
+ return String(this.cart.coupon_code || '').toUpperCase() === this.offeredCoupon.code.toUpperCase()
66
+ }
50
67
  },
51
68
  methods: {
52
69
  ...mapMutations(['setCart']),
53
70
 
54
71
  formatMoney,
55
72
 
73
+ applyCode(code) {
74
+ this.couponCode = code
75
+ this.applyCoupon()
76
+ },
77
+
56
78
  applyCoupon() {
57
79
  this.acLoading = true
58
80
  request({
package/locales/en.json CHANGED
@@ -93,6 +93,7 @@
93
93
  "accountExistsError": "There is an existing account associated with this email address. Please sign in to continue or use a different email address.",
94
94
  "addToCart": "Add to cart",
95
95
  "applyCoupon": "Apply",
96
+ "applyOfferedCoupon": "Apply",
96
97
  "billingAddressError": "Please select billing address",
97
98
  "buyNow": "Buy now",
98
99
  "cart": "Cart",
@@ -105,6 +106,7 @@
105
106
  "continue": "Continue",
106
107
  "continueShopping": "Continue shopping",
107
108
  "continueToPayment": "Continue to payment",
109
+ "couponValidUntil": "Valid until {date}.",
108
110
  "deliveryCost": "",
109
111
  "deliveryCostFree": "FREE",
110
112
  "deliverToThisAddress": "Deliver to this address",
@@ -123,6 +125,7 @@
123
125
  "itemAdded": "Item added to your cart",
124
126
  "itemsShippedFrom": "Items shipped from {0}",
125
127
  "lBillingAddressSameAsDelivery": "Billing address same as delivery",
128
+ "offeredCoupon": "Your discount code",
126
129
  "orderDate": "Order time:",
127
130
  "orderInfo": "\n A confirmation email will be sent to\n <strong>{0}</strong> once your order has been processed. You will receive another email with tracking information once your order\n has been shipped. In the unlikely event that we anticipate a delay, you will be notified via email.\n ",
128
131
  "orderNumber": "Order number: ",
package/locales/sr.json CHANGED
@@ -93,6 +93,7 @@
93
93
  "accountExistsError": "Već postoji nalog sa unetom email adresom. Molimo vas da se ulogujete ili da unesete drugu email adresu.",
94
94
  "addToCart": "Dodaj u korpu",
95
95
  "applyCoupon": "Primeni kupon",
96
+ "applyOfferedCoupon": "Primeni kupon",
96
97
  "billingAddressError": "Odaberite adresu za naplatu",
97
98
  "buyNow": "Kupi odmah",
98
99
  "cart": "Korpa",
@@ -105,6 +106,7 @@
105
106
  "continue": "Dalje",
106
107
  "continueShopping": "Nastavite sa kupovinom",
107
108
  "continueToPayment": "Nastavite sa plaćanjem",
109
+ "couponValidUntil": "Kupon važi do {date}.",
108
110
  "deliveryCost": "Cena isporuke:",
109
111
  "deliveryCostFree": "Besplatna isporuka",
110
112
  "deliverToThisAddress": "Dostavite na ovu adresu",
@@ -123,6 +125,7 @@
123
125
  "itemAdded": "Proizvod je dodat u vašu korpu",
124
126
  "itemsShippedFrom": "Isporučuje {0}",
125
127
  "lBillingAddressSameAsShipping": "Adresa za naplatu ista kao i adresa za isporuku",
128
+ "offeredCoupon": "Vaš kod za popust",
126
129
  "orderDate": "Datum narudžbenice:",
127
130
  "orderInfo": "\n Potvrda će biti poslata na \n <strong>{0}</strong> kada vaša narudžbenica bude obrađena. Dobićete još jedan mail kada kurirska služba preuzme pošiljku. U slučaju da nastupi neki problem takođe ćemo vas obavestiti na email.\n",
128
131
  "orderNumber": "Broj narudžbenice:",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wikala/spmkt",
3
- "version": "2.30.0",
3
+ "version": "2.31.1",
4
4
  "private": false,
5
5
  "description": "supermarket",
6
6
  "scripts": {
@@ -1,10 +0,0 @@
1
- {
2
- "permissions": {
3
- "allow": [
4
- "Bash(grep:*)",
5
- "Bash(head:*)",
6
- "Bash(git -C /Users/svp/projects/fe-supermarket log --all --name-only --oneline api/index.js)",
7
- "Bash(git -C /Users/svp/projects/fe-supermarket status --short)"
8
- ]
9
- }
10
- }