web-manager 3.2.13 → 3.2.15
Sign up to get free protection for your applications and to get access to all the features.
- package/lib/account.js +23 -10
- package/package.json +1 -1
package/lib/account.js
CHANGED
@@ -11,7 +11,9 @@ function Account(init) {
|
|
11
11
|
self.dom = init.dom || self.Manager.dom();
|
12
12
|
self.utilities = init.utilities || self.Manager.utilities();
|
13
13
|
|
14
|
-
|
14
|
+
var url = new URL(window.location.href);
|
15
|
+
|
16
|
+
if (url.pathname.startsWith('/account')) {
|
15
17
|
self.initializeAccountPage();
|
16
18
|
}
|
17
19
|
} catch (e) {
|
@@ -102,9 +104,10 @@ Account.prototype.resolve = function (account, options) {
|
|
102
104
|
|
103
105
|
account = account || {};
|
104
106
|
options = options || {};
|
107
|
+
options.fetchNewAccount = typeof options.fetchNewAccount === 'undefined' ? true : options.fetchNewAccount;
|
105
108
|
|
106
109
|
// If there is no user logged in or we choose not to fetch the account, resolve a default account
|
107
|
-
if (!currentUser || !currentUser.uid || options.fetchNewAccount
|
110
|
+
if (!currentUser || !currentUser.uid || !options.fetchNewAccount) {
|
108
111
|
return resolve(
|
109
112
|
self.handleAccount(
|
110
113
|
self._resolveAccount(currentUser, account, options)
|
@@ -273,11 +276,11 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
273
276
|
currentURL = new URL(window.location.href);
|
274
277
|
isDevelopment = self.utilities.get(self.Manager, 'properties.meta.environment', '') === 'development';
|
275
278
|
|
276
|
-
if (
|
279
|
+
if (isDevelopment) {
|
277
280
|
currentURL.searchParams
|
278
281
|
.forEach(function(value, key) {
|
279
282
|
var accountValue = self.utilities.get(account, key, undefined)
|
280
|
-
if (typeof accountValue !== undefined) {
|
283
|
+
if (typeof accountValue !== 'undefined') {
|
281
284
|
if (value === 'true') { value = true }
|
282
285
|
if (value === 'false') { value = false }
|
283
286
|
|
@@ -297,6 +300,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
297
300
|
var difference = (planExpireDate.getTime() - now.getTime()) / (24 * 3600 * 1000);
|
298
301
|
var startDate = new Date(account.plan.payment.startDate.timestamp);
|
299
302
|
var planIsActive = difference > -1 && account.plan.id !== defaultPlanId;
|
303
|
+
var planIsSuspended = account.plan.status === 'suspended';
|
300
304
|
|
301
305
|
if (planIsActive) {
|
302
306
|
account.plan.id = account.plan.id;
|
@@ -379,7 +383,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
379
383
|
// Set UI elements
|
380
384
|
// In a try/catch because this lib is used in node sometimes
|
381
385
|
try {
|
382
|
-
var cancelURL = isDevelopment ? 'http://localhost:4001/cancel
|
386
|
+
var cancelURL = isDevelopment ? 'http://localhost:4001/cancel' : 'https://itwcreativeworks.com/portal/account/manage';
|
383
387
|
|
384
388
|
var billingSubscribeBtn = self.dom.select('.auth-billing-subscribe-btn');
|
385
389
|
var billingUpdateBtn = self.dom.select('.auth-billing-update-btn');
|
@@ -387,6 +391,7 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
387
391
|
var billingFrequencyEl = self.dom.select('.auth-billing-frequency-element');
|
388
392
|
var billingStartDateEl = self.dom.select('.auth-billing-start-date-element');
|
389
393
|
var billingExpirationDateEl = self.dom.select('.auth-billing-expiration-date-element');
|
394
|
+
var billingSuspendedMessageEl = self.dom.select('.auth-billing-suspended-message-element');
|
390
395
|
|
391
396
|
var $referralCount = self.dom.select('.auth-referral-count-element');
|
392
397
|
var $referralCode = self.dom.select('.auth-referral-code-element');
|
@@ -420,18 +425,26 @@ Account.prototype._resolveAccount = function (firebaseUser, account, options) {
|
|
420
425
|
)
|
421
426
|
authPhoneInput.setInnerHTML(firebaseUser.phoneNumber).setValue(firebaseUser.phoneNumber)
|
422
427
|
|
428
|
+
billingUpdateBtn.setAttribute('hidden', true).setAttribute('href', updateURL.toString());
|
423
429
|
billingSubscribeBtn.setAttribute('hidden', true);
|
424
|
-
|
430
|
+
billingSuspendedMessageEl.setAttribute('hidden');
|
425
431
|
|
426
|
-
|
427
|
-
|
428
|
-
updateURL.searchParams.set('resourceId', account.plan.payment.resourceId);
|
432
|
+
updateURL.searchParams.set('orderId', account.plan.payment.orderId);
|
433
|
+
updateURL.searchParams.set('resourceId', account.plan.payment.resourceId);
|
429
434
|
|
430
|
-
|
435
|
+
if (planIsActive) {
|
436
|
+
billingUpdateBtn.removeAttribute('hidden');
|
431
437
|
} else {
|
432
438
|
billingSubscribeBtn.removeAttribute('hidden');
|
433
439
|
}
|
434
440
|
|
441
|
+
if (planIsSuspended) {
|
442
|
+
billingUpdateBtn.removeAttribute('hidden');
|
443
|
+
billingSubscribeBtn.setAttribute('hidden', true);
|
444
|
+
|
445
|
+
billingSuspendedMessageEl.removeAttribute('hidden');
|
446
|
+
}
|
447
|
+
|
435
448
|
billingPlanId.setInnerHTML(uppercase(account.plan.id));
|
436
449
|
billingFrequencyEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' (billed ' + uppercase(account.plan.payment.frequency) + ')' : '');
|
437
450
|
billingStartDateEl.setInnerHTML(account.plan.id !== defaultPlanId ? ' - Purchased ' + getMonth(startDate) + ' ' + startDate.getDate() + ', ' + startDate.getFullYear() : '');
|
package/package.json
CHANGED