web-manager 3.2.15 → 3.2.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. package/lib/account.js +18 -4
  2. package/package.json +2 -2
package/lib/account.js CHANGED
@@ -294,10 +294,12 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
294
294
  }
295
295
  }
296
296
 
297
- var planExpireDate = new Date(account.plan.expires.timestamp);
298
297
  var now = new Date();
298
+ var planExpireDate = new Date(account.plan.expires.timestamp);
299
299
  var daysTillExpire = Math.floor((planExpireDate - now) / 86400000);
300
300
  var difference = (planExpireDate.getTime() - now.getTime()) / (24 * 3600 * 1000);
301
+ var trialExpireDate = new Date(account.plan.trial.expires.timestamp);
302
+ var daysTillTrialExpire = Math.floor((trialExpireDate - now) / 86400000);
301
303
  var startDate = new Date(account.plan.payment.startDate.timestamp);
302
304
  var planIsActive = difference > -1 && account.plan.id !== defaultPlanId;
303
305
  var planIsSuspended = account.plan.status === 'suspended';
@@ -392,6 +394,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
392
394
  var billingStartDateEl = self.dom.select('.auth-billing-start-date-element');
393
395
  var billingExpirationDateEl = self.dom.select('.auth-billing-expiration-date-element');
394
396
  var billingSuspendedMessageEl = self.dom.select('.auth-billing-suspended-message-element');
397
+ var billingTrialExpirationDateEl = self.dom.select('.auth-billing-trial-expiration-date-element');
395
398
 
396
399
  var $referralCount = self.dom.select('.auth-referral-count-element');
397
400
  var $referralCode = self.dom.select('.auth-referral-code-element');
@@ -425,19 +428,22 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
425
428
  )
426
429
  authPhoneInput.setInnerHTML(firebaseUser.phoneNumber).setValue(firebaseUser.phoneNumber)
427
430
 
431
+ updateURL.searchParams.set('orderId', account.plan.payment.orderId);
432
+ updateURL.searchParams.set('resourceId', account.plan.payment.resourceId);
433
+
428
434
  billingUpdateBtn.setAttribute('hidden', true).setAttribute('href', updateURL.toString());
429
435
  billingSubscribeBtn.setAttribute('hidden', true);
430
436
  billingSuspendedMessageEl.setAttribute('hidden');
437
+ billingTrialExpirationDateEl.setAttribute('hidden');
431
438
 
432
- updateURL.searchParams.set('orderId', account.plan.payment.orderId);
433
- updateURL.searchParams.set('resourceId', account.plan.payment.resourceId);
434
-
439
+ // Update active UI
435
440
  if (planIsActive) {
436
441
  billingUpdateBtn.removeAttribute('hidden');
437
442
  } else {
438
443
  billingSubscribeBtn.removeAttribute('hidden');
439
444
  }
440
445
 
446
+ // Update suspended UI
441
447
  if (planIsSuspended) {
442
448
  billingUpdateBtn.removeAttribute('hidden');
443
449
  billingSubscribeBtn.setAttribute('hidden', true);
@@ -445,6 +451,14 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
445
451
  billingSuspendedMessageEl.removeAttribute('hidden');
446
452
  }
447
453
 
454
+ // Update trial UI
455
+ if (account.plan.trial.activated) {
456
+ billingTrialExpirationDateEl
457
+ .removeAttribute('hidden')
458
+ .setInnerHTML('<i class="fas fa-gift mr-1"></i> Your free trial expires in ' + daysTillTrialExpire + ' days');
459
+ }
460
+
461
+ // Update billing UI
448
462
  billingPlanId.setInnerHTML(uppercase(account.plan.id));
449
463
  billingFrequencyEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' (billed ' + uppercase(account.plan.payment.frequency) + ')' : '');
450
464
  billingStartDateEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' - Purchased ' + getMonth(startDate) + ' ' + startDate.getDate() + ', ' + startDate.getFullYear() : '');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.15",
3
+ "version": "3.2.16",
4
4
  "description": "Easily access important variables such as the query string, current domain, and current page in a single object.",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -36,4 +36,4 @@
36
36
  "firebase": "^9.23.0",
37
37
  "lazysizes": "^5.3.2"
38
38
  }
39
- }
39
+ }