web-manager 3.2.39 → 3.2.40

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 +42 -4
  2. package/package.json +2 -2
package/lib/account.js CHANGED
@@ -240,6 +240,9 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
240
240
  console.log('++++++account', JSON.stringify(account, null, 2));
241
241
  console.log('++++++options', JSON.stringify(options, null, 2));
242
242
 
243
+ // @@@DEVELOPER
244
+ // account.plan = {};
245
+
243
246
  // Resolve auth
244
247
  account.auth = account.auth || {};
245
248
  account.auth.uid = account.auth.uid || firebaseUser.uid || null;
@@ -262,6 +265,17 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
262
265
  account.plan.trial.expires.timestamp = new Date(account.plan.trial.expires.timestamp || 0).toISOString()
263
266
  account.plan.trial.expires.timestampUNIX = Math.round(new Date(account.plan.trial.expires.timestamp || 0).getTime() / 1000);
264
267
 
268
+ // @@@DEVELOPER
269
+ // account.plan.id = 'basic';
270
+ // account.plan.trial = {
271
+ // activated: false,
272
+ // expires: {
273
+ // timestamp: new Date('2024-04-23T00:07:29.183Z').toISOString(),
274
+ // timestampUNIX: Math.round(new Date('2024-04-23T00:07:29.183Z').getTime() / 1000),
275
+ // }
276
+ // }
277
+ // account.plan.status = 'suspended';
278
+
265
279
  account.plan.limits = account.plan.limits || {};
266
280
  // account.plan.devices = account.plan.devices || 1;
267
281
 
@@ -324,6 +338,8 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
324
338
  account.plan.id = defaultPlanId;
325
339
  }
326
340
 
341
+ var isBasicPlan = account.plan.id === defaultPlanId;
342
+
327
343
  // Resolve oAuth2
328
344
  account.oauth2 = account.oauth2 || {};
329
345
  // account.oauth2.google = account.oauth2.google || {};
@@ -331,7 +347,6 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
331
347
 
332
348
  // Resolve roles
333
349
  account.roles = account.roles || {};
334
- // account.roles.betaTester = account.plan.id === defaultPlanId ? false : account.roles.betaTester === true || account.roles.betaTester === 'true';
335
350
  account.roles.betaTester = account.roles.betaTester === true || account.roles.betaTester === 'true';
336
351
  account.roles.developer = account.roles.developer === true || account.roles.developer === 'true';
337
352
  account.roles.admin = account.roles.admin === true || account.roles.admin === 'true';
@@ -418,6 +433,8 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
418
433
  var billingUpdateBtn = self.dom.select('.auth-billing-update-btn');
419
434
  var billingPlanId = self.dom.select('.auth-billing-plan-id-element');
420
435
  var billingFrequencyEl = self.dom.select('.auth-billing-frequency-element');
436
+ var billingStatusEl = self.dom.select('.auth-billing-status-element');
437
+ var billingStatusColorEl = self.dom.select('.auth-billing-status-color-element');
421
438
  var billingStartDateEl = self.dom.select('.auth-billing-start-date-element');
422
439
  var billingExpirationDateEl = self.dom.select('.auth-billing-expiration-date-element');
423
440
  var billingSuspendedMessageEl = self.dom.select('.auth-billing-suspended-message-element');
@@ -488,11 +505,32 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
488
505
  .setInnerHTML('<i class="fas fa-gift mr-1"></i> Your free trial expires in ' + daysTillTrialExpire + ' days');
489
506
  }
490
507
 
508
+ // Change the status to 'failed' if the plan is suspended because room temperature IQ people think 'suspended' means 'cancelled'
509
+ var visibleStatus = uppercase(account.plan.status === 'suspended' ? 'failed payment' : account.plan.status);
510
+ // If user is on trial, start date is trial exp date
511
+ var visibleStartDate = account.plan.trial.activated ? account.plan.trial.expires.timestamp : account.plan.payment.startDate.timestamp;
512
+ if (isBasicPlan) {
513
+ // Set as start of this month
514
+ visibleStartDate = new Date(now.getFullYear(), now.getMonth(), 1).toISOString();
515
+ }
516
+ var visibleFrequency = account.plan.payment.frequency === 'unknown' ? 'monthly' : account.plan.payment.frequency;
517
+
491
518
  // Update billing UI
492
519
  billingPlanId.setInnerHTML(splitDashesAndUppercase(account.plan.id));
493
- billingFrequencyEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' (billed ' + uppercase(account.plan.payment.frequency) + ')' : '');
494
- billingStartDateEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' - Purchased ' + getMonth(startDate) + ' ' + startDate.getDate() + ', ' + startDate.getFullYear() : '');
495
- billingExpirationDateEl.setInnerHTML(account.plan.id !== defaultPlanId && daysTillExpire < 366
520
+ billingFrequencyEl.setInnerHTML(visibleFrequency);
521
+ billingStatusEl.setInnerHTML(visibleStatus);
522
+ billingStatusColorEl
523
+ .removeClass('bg-soft-success').removeClass('bg-soft-danger').removeClass('bg-soft-warning')
524
+ .removeClass('text-success').removeClass('text-danger').removeClass('text-warning')
525
+ if (account.plan.status === 'active') {
526
+ billingStatusColorEl.addClass('bg-soft-success').addClass('text-success');
527
+ } else {
528
+ billingStatusColorEl.addClass('bg-soft-danger').addClass('text-danger');
529
+ }
530
+ billingStartDateEl.setInnerHTML(new Date(visibleStartDate).toLocaleString(undefined, {
531
+ weekday: 'long', year: 'numeric', month: 'long', day: 'numeric',
532
+ }));
533
+ billingExpirationDateEl.setInnerHTML(isBasicPlan && daysTillExpire < 366
496
534
  ? '<i class="fas fa-exclamation-triangle mr-1"></i> Expires in ' + daysTillExpire + ' days '
497
535
  : '');
498
536
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "web-manager",
3
- "version": "3.2.39",
3
+ "version": "3.2.40",
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
+ }