1212 </button >
1313 <div class =" promo-banner__body" >
1414 <div class =" discount" >
15- <div class =" discount__percentage" >{{ discount }}</div >
15+ <div class =" discount__percentage" >{{ active_promotion. discount }}</div >
1616 <div class =" discount__off" >OFF</div >
1717 </div >
1818 <div >
19- <div class =" code" >
19+ <div class =" code" @click = " copyCode " >
2020 Use promo code
21- <div >{{ code }}</div >
21+ <div >
22+ {{ active_promotion.code }}
23+ <hk-icon icon =" fas fa-copy" class =" ml-1" />
24+ </div >
2225 </div >
2326 </div >
2427 </div >
2528 <div class =" promo-banner__footer" >
2629 <div class =" remaining" >
27- Get your first month with a <strong >{{ discount }}%</strong > discount.
30+ Get your first month with a <strong >{{ active_promotion. discount }}%</strong > discount.
2831 <template v-if =" hours_remaining <= 1 " >Less than </template >
2932 <span class =" remaining__count" >{{
3033 days_remaining ? days_remaining : hours_remaining
3841
3942<script >
4043import { mapGetters } from " vuex" ;
44+ import { promotionService } from " src/services/promotions" ;
4145
4246export default {
4347 name: " PromoBanner" ,
@@ -49,50 +53,50 @@ export default {
4953 },
5054 data () {
5155 return {
56+ active_promotion: undefined ,
5257 code: " SHIELDMAIDEN80" ,
53- discount: 80 ,
5458 now: new Date (),
55- start: new Date (" 2024-11-15T00:00:00Z" ),
56- end: new Date (" 2024-12-03T07:59:59Z" ),
5759 showSetter: undefined ,
5860 timer: null ,
5961 };
6062 },
6163 computed: {
6264 ... mapGetters ([" tier" ]),
63- show_banner: {
64- get () {
65- const show =
66- (this .tier ? .price === " Free" || ! this .tier ) &&
67- this .now >= this .start &&
68- this .now <= this .end ;
69- return this .showSetter !== undefined ? this .showSetter : show;
70- },
71- set (newVal ) {
72- this .showSetter = newVal;
73- },
65+ show_banner () {
66+ return this .active_promotion && (this .tier ? .price === " Free" || ! this .tier );
7467 },
7568 days_remaining () {
76- const diff = this .end - this .now ;
69+ const diff = this .active_promotion . active_until - this .now ;
7770 const days = Math .floor (diff / (1000 * 60 * 60 * 24 ));
7871 return days >= 1 ? days : undefined ;
7972 },
8073 hours_remaining () {
81- const diff = this .end - this .now ;
74+ const diff = this .active_promotion . active_until - this .now ;
8275 const hours = Math .floor (diff / (1000 * 60 * 60 ));
8376 return hours;
8477 },
8578 },
8679 methods: {
80+ copyCode (event ) {
81+ event .preventDefault ();
82+ navigator .clipboard .writeText (this .active_promotion .code );
83+ this .$snotify .success (" To clipboard" , " Code Copied!" , {
84+ position: " rightTop" ,
85+ });
86+ },
87+ async getActivePromotion () {
88+ return await promotionService .getFirstActivePromotion ();
89+ },
8790 purchaseEvent () {
8891 this .$gtm .trackEvent ({
8992 event : " purchase" ,
9093 });
9194 },
9295 },
93- mounted () {
94- if (this .show_banner ) {
95- this .$emit (" discount" , this .discount );
96+ async mounted () {
97+ this .active_promotion = await this .getActivePromotion ();
98+ if (this .show_banner && this .active_promotion ) {
99+ this .$emit (" discount" , this .active_promotion .discount );
96100 }
97101 this .timer = setInterval (() => {
98102 this .now = new Date ();
@@ -137,6 +141,9 @@ export default {
137141
138142 .code {
139143 color: $neutral- 2 ;
144+ : hover {
145+ color: $primary;
146+ }
140147
141148 > div {
142149 color: $white;
0 commit comments