diff --git a/website/client/src/components/shops/buyModal.vue b/website/client/src/components/shops/buyModal.vue
index 2a4a793c20..13e4b7ac05 100644
--- a/website/client/src/components/shops/buyModal.vue
+++ b/website/client/src/components/shops/buyModal.vue
@@ -161,16 +161,10 @@
-
-
- {{ limitedString }}
-
+ :endDate = "endDate"
+ />
+
+
+ {{ limitedString }}
+
+
+
+
+
+
diff --git a/website/client/src/components/shops/market/categoryRow.vue b/website/client/src/components/shops/market/categoryRow.vue
index 92012294b6..d63e92ded2 100644
--- a/website/client/src/components/shops/market/categoryRow.vue
+++ b/website/client/src/components/shops/market/categoryRow.vue
@@ -48,6 +48,12 @@ export default {
},
mixins: [pinUtils],
props: ['hideLocked', 'hidePinned', 'searchBy', 'sortBy', 'category'],
+ data () {
+ return {
+ timer: '',
+ limitedString: '',
+ };
+ },
computed: {
...mapState({
content: 'content',
@@ -60,9 +66,6 @@ export default {
return planGemLimits.convCap
+ this.user.purchased.plan.consecutive.gemCapExtra - this.user.purchased.plan.gemsBought;
},
- limitedString () {
- return this.$t('limitedOffer', { date: moment(seasonalShopConfig.dateRange.end).format('LL') });
- },
sortedMarketItems () {
let result = _map(this.category.items, e => ({
...e,
@@ -103,10 +106,36 @@ export default {
return result;
},
},
+ mounted () {
+ this.countdownString();
+ this.timer = setInterval(this.countdownString, 30000);
+ },
methods: {
itemSelected (item) {
this.$root.$emit('buyModal::showItem', item);
},
+ countdownString () {
+ const diffDuration = moment.duration(moment(seasonalShopConfig.dateRange.end).diff(moment()));
+
+ if (diffDuration.days() > 0) {
+ this.limitedString = this.$t('limitedAvailabilityDays', {
+ days: diffDuration.days(),
+ hours: diffDuration.hours(),
+ minutes: diffDuration.minutes(),
+ });
+ } else {
+ this.limitedString = this.$t('limitedAvailabilityHours', {
+ hours: diffDuration.hours(),
+ minutes: diffDuration.minutes(),
+ });
+ }
+ },
+ cancelAutoUpdate () {
+ clearInterval(this.timer);
+ },
+ },
+ beforeDestroy () {
+ this.cancelAutoUpdate();
},
};
diff --git a/website/client/src/components/shops/quests/buyQuestModal.vue b/website/client/src/components/shops/quests/buyQuestModal.vue
index a11e3bc05c..da8bf6b1b7 100644
--- a/website/client/src/components/shops/quests/buyQuestModal.vue
+++ b/website/client/src/components/shops/quests/buyQuestModal.vue
@@ -84,16 +84,10 @@
>
-
-
- {{ limitedString }}
-
+ :endDate="endDate"
+ />
diff --git a/website/client/src/components/shops/shopItem.vue b/website/client/src/components/shops/shopItem.vue
index f3bc30e77c..d2bc6c228c 100644
--- a/website/client/src/components/shops/shopItem.vue
+++ b/website/client/src/components/shops/shopItem.vue
@@ -291,16 +291,18 @@ export default {
},
},
data () {
- return Object.freeze({
+ return {
itemId: uuid(),
- icons: {
+ icons: Object.freeze({
gems: svgGem,
gold: svgGold,
lock: svgLock,
hourglasses: svgHourglasses,
clock: svgClock,
- },
- });
+ }),
+ timer: '',
+ limitedString: '',
+ };
},
computed: {
showNotes () {
@@ -314,10 +316,10 @@ export default {
}
return 'gold';
},
- limitedString () {
- return this.item.owned === false ? ''
- : this.$t('limitedOffer', { date: moment(seasonalShopConfig.dateRange.end).format('LL') });
- },
+ },
+ mounted () {
+ this.countdownString();
+ this.timer = setInterval(this.countdownString, 30000);
},
methods: {
click () {
@@ -338,6 +340,28 @@ export default {
locked: this.item.locked,
};
},
+ countdownString () {
+ const diffDuration = moment.duration(moment(seasonalShopConfig.dateRange.end).diff(moment()));
+
+ if (diffDuration.days() > 0) {
+ this.limitedString = this.$t('limitedAvailabilityDays', {
+ days: diffDuration.days(),
+ hours: diffDuration.hours(),
+ minutes: diffDuration.minutes(),
+ });
+ } else {
+ this.limitedString = this.$t('limitedAvailabilityHours', {
+ hours: diffDuration.hours(),
+ minutes: diffDuration.minutes(),
+ });
+ }
+ },
+ cancelAutoUpdate () {
+ clearInterval(this.timer);
+ },
+ },
+ beforeDestroy () {
+ this.cancelAutoUpdate();
},
};
diff --git a/website/common/locales/en/npc.json b/website/common/locales/en/npc.json
index 684e6ac81b..d4461ec9fa 100644
--- a/website/common/locales/en/npc.json
+++ b/website/common/locales/en/npc.json
@@ -125,5 +125,7 @@
"welcome3": "Progress in life and the game!",
"welcome3notes": "As you improve your life, your avatar will level up and unlock pets, quests, equipment, and more!",
"imReady": "Enter Habitica",
- "limitedOffer": "Available until <%= date %>"
+ "limitedOffer": "Available until <%= date %>",
+ "limitedAvailabilityDays": "Available for <%= days %>d <%= hours %>h <%= minutes %>m",
+ "limitedAvailabilityHours": "Available for <%= hours %>h <%= minutes %>m"
}