diff options
author | Stefan Malzner <stefan@adlk.io> | 2019-10-16 15:16:26 +0200 |
---|---|---|
committer | Stefan Malzner <stefan@adlk.io> | 2019-10-16 15:16:26 +0200 |
commit | 0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba (patch) | |
tree | 9ee5b287f3c0451012153cf281659159597d63e7 /src/stores/PaymentStore.js | |
parent | polishing (diff) | |
download | ferdium-app-0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba.tar.gz ferdium-app-0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba.tar.zst ferdium-app-0b08e1e7e6a07acd21af71fd27f4c4acfa34dbba.zip |
Add trialStatusBar & polishing
Diffstat (limited to 'src/stores/PaymentStore.js')
-rw-r--r-- | src/stores/PaymentStore.js | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/stores/PaymentStore.js b/src/stores/PaymentStore.js index d4de476c8..b90e8f006 100644 --- a/src/stores/PaymentStore.js +++ b/src/stores/PaymentStore.js | |||
@@ -1,10 +1,13 @@ | |||
1 | import { action, observable, computed } from 'mobx'; | 1 | import { action, observable, computed } from 'mobx'; |
2 | import { remote } from 'electron'; | ||
2 | 3 | ||
3 | import Store from './lib/Store'; | 4 | import Store from './lib/Store'; |
4 | import CachedRequest from './lib/CachedRequest'; | 5 | import CachedRequest from './lib/CachedRequest'; |
5 | import Request from './lib/Request'; | 6 | import Request from './lib/Request'; |
6 | import { gaEvent } from '../lib/analytics'; | 7 | import { gaEvent } from '../lib/analytics'; |
7 | 8 | ||
9 | const { BrowserWindow } = remote; | ||
10 | |||
8 | export default class PaymentStore extends Store { | 11 | export default class PaymentStore extends Store { |
9 | @observable plansRequest = new CachedRequest(this.api.payment, 'plans'); | 12 | @observable plansRequest = new CachedRequest(this.api.payment, 'plans'); |
10 | 13 | ||
@@ -14,6 +17,7 @@ export default class PaymentStore extends Store { | |||
14 | super(...args); | 17 | super(...args); |
15 | 18 | ||
16 | this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this)); | 19 | this.actions.payment.createHostedPage.listen(this._createHostedPage.bind(this)); |
20 | this.actions.payment.upgradeAccount.listen(this._upgradeAccount.bind(this)); | ||
17 | } | 21 | } |
18 | 22 | ||
19 | @computed get plan() { | 23 | @computed get plan() { |
@@ -30,4 +34,37 @@ export default class PaymentStore extends Store { | |||
30 | 34 | ||
31 | return request; | 35 | return request; |
32 | } | 36 | } |
37 | |||
38 | @action _upgradeAccount({ planId, onCloseWindow = () => null }) { | ||
39 | let hostedPageURL = this.stores.features.features.subscribeURL; | ||
40 | |||
41 | const parsedUrl = new URL(hostedPageURL); | ||
42 | const params = new URLSearchParams(parsedUrl.search.slice(1)); | ||
43 | |||
44 | params.set('plan', planId); | ||
45 | |||
46 | hostedPageURL = this.stores.user.getAuthURL(`${parsedUrl.origin}${parsedUrl.pathname}?${params.toString()}`); | ||
47 | |||
48 | const win = new BrowserWindow({ | ||
49 | parent: remote.getCurrentWindow(), | ||
50 | modal: true, | ||
51 | title: '🔒 Upgrade Your Franz Account', | ||
52 | width: 800, | ||
53 | height: window.innerHeight - 100, | ||
54 | maxWidth: 800, | ||
55 | minWidth: 600, | ||
56 | webPreferences: { | ||
57 | nodeIntegration: true, | ||
58 | webviewTag: true, | ||
59 | }, | ||
60 | }); | ||
61 | win.loadURL(`file://${__dirname}/../index.html#/payment/${encodeURIComponent(hostedPageURL)}`); | ||
62 | |||
63 | win.on('closed', () => { | ||
64 | this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); | ||
65 | this.stores.features.featuresRequest.invalidate({ immediately: true }); | ||
66 | |||
67 | onCloseWindow(); | ||
68 | }); | ||
69 | } | ||
33 | } | 70 | } |