diff options
Diffstat (limited to 'src/stores/UserStore.js')
-rw-r--r-- | src/stores/UserStore.js | 41 |
1 files changed, 14 insertions, 27 deletions
diff --git a/src/stores/UserStore.js b/src/stores/UserStore.js index 297ea1121..d6a2e5fde 100644 --- a/src/stores/UserStore.js +++ b/src/stores/UserStore.js | |||
@@ -8,12 +8,11 @@ import { isDevMode } from '../environment'; | |||
8 | import Store from './lib/Store'; | 8 | import Store from './lib/Store'; |
9 | import Request from './lib/Request'; | 9 | import Request from './lib/Request'; |
10 | import CachedRequest from './lib/CachedRequest'; | 10 | import CachedRequest from './lib/CachedRequest'; |
11 | import { gaEvent } from '../lib/analytics'; | ||
12 | import { sleep } from '../helpers/async-helpers'; | 11 | import { sleep } from '../helpers/async-helpers'; |
13 | import { getPlan } from '../helpers/plan-helpers'; | 12 | import { getPlan } from '../helpers/plan-helpers'; |
14 | import { PLANS } from '../config'; | 13 | import { PLANS } from '../config'; |
15 | 14 | ||
16 | const debug = require('debug')('Franz:UserStore'); | 15 | const debug = require('debug')('Ferdi:UserStore'); |
17 | 16 | ||
18 | // TODO: split stores into UserStore and AuthStore | 17 | // TODO: split stores into UserStore and AuthStore |
19 | export default class UserStore extends Store { | 18 | export default class UserStore extends Store { |
@@ -57,6 +56,8 @@ export default class UserStore extends Store { | |||
57 | 56 | ||
58 | @observable isImportLegacyServicesCompleted = false; | 57 | @observable isImportLegacyServicesCompleted = false; |
59 | 58 | ||
59 | @observable isLoggingOut = false; | ||
60 | |||
60 | @observable id; | 61 | @observable id; |
61 | 62 | ||
62 | @observable authToken = localStorage.getItem('authToken') || null; | 63 | @observable authToken = localStorage.getItem('authToken') || null; |
@@ -96,7 +97,7 @@ export default class UserStore extends Store { | |||
96 | 97 | ||
97 | // Reactions | 98 | // Reactions |
98 | this.registerReactions([ | 99 | this.registerReactions([ |
99 | this._requireAuthenticatedUser, | 100 | // this._requireAuthenticatedUser, |
100 | this._getUserData.bind(this), | 101 | this._getUserData.bind(this), |
101 | this._resetTrialActivationState.bind(this), | 102 | this._resetTrialActivationState.bind(this), |
102 | ]); | 103 | ]); |
@@ -159,7 +160,7 @@ export default class UserStore extends Store { | |||
159 | } | 160 | } |
160 | 161 | ||
161 | @computed get isPremium() { | 162 | @computed get isPremium() { |
162 | return !!this.data.isPremium; | 163 | return true; |
163 | } | 164 | } |
164 | 165 | ||
165 | @computed get isPremiumOverride() { | 166 | @computed get isPremiumOverride() { |
@@ -174,12 +175,13 @@ export default class UserStore extends Store { | |||
174 | } | 175 | } |
175 | 176 | ||
176 | @computed get isPro() { | 177 | @computed get isPro() { |
177 | if (this.isPremiumOverride) return true; | 178 | return true; |
179 | // if (this.isPremiumOverride) return true; | ||
178 | 180 | ||
179 | if (!this.team || (!this.team.plan || this.team.state === 'expired')) return false; | 181 | // if (!this.team || (!this.team.plan || this.team.state === 'expired')) return false; |
180 | const plan = getPlan(this.team.plan); | 182 | // const plan = getPlan(this.team.plan); |
181 | 183 | ||
182 | return plan === PLANS.PRO || plan === PLANS.LEGACY; | 184 | // return plan === PLANS.PRO || plan === PLANS.LEGACY; |
183 | } | 185 | } |
184 | 186 | ||
185 | @computed get legacyServices() { | 187 | @computed get legacyServices() { |
@@ -192,16 +194,12 @@ export default class UserStore extends Store { | |||
192 | this._setUserData(authToken); | 194 | this._setUserData(authToken); |
193 | 195 | ||
194 | this.stores.router.push('/'); | 196 | this.stores.router.push('/'); |
195 | |||
196 | gaEvent('User', 'login'); | ||
197 | } | 197 | } |
198 | 198 | ||
199 | @action _tokenLogin(authToken) { | 199 | @action _tokenLogin(authToken) { |
200 | this._setUserData(authToken); | 200 | this._setUserData(authToken); |
201 | 201 | ||
202 | this.stores.router.push('/'); | 202 | this.stores.router.push('/'); |
203 | |||
204 | gaEvent('User', 'tokenLogin'); | ||
205 | } | 203 | } |
206 | 204 | ||
207 | @action async _signup({ | 205 | @action async _signup({ |
@@ -219,13 +217,11 @@ export default class UserStore extends Store { | |||
219 | currency, | 217 | currency, |
220 | }); | 218 | }); |
221 | 219 | ||
222 | this.hasCompletedSignup = false; | 220 | this.hasCompletedSignup = true; |
223 | 221 | ||
224 | this._setUserData(authToken); | 222 | this._setUserData(authToken); |
225 | 223 | ||
226 | this.stores.router.push(this.PRICING_ROUTE); | 224 | this.stores.router.push('/'); |
227 | |||
228 | gaEvent('User', 'signup'); | ||
229 | } | 225 | } |
230 | 226 | ||
231 | @action async _retrievePassword({ email }) { | 227 | @action async _retrievePassword({ email }) { |
@@ -233,8 +229,6 @@ export default class UserStore extends Store { | |||
233 | 229 | ||
234 | await request._promise; | 230 | await request._promise; |
235 | this.actionStatus = request.result.status || []; | 231 | this.actionStatus = request.result.status || []; |
236 | |||
237 | gaEvent('User', 'retrievePassword'); | ||
238 | } | 232 | } |
239 | 233 | ||
240 | @action async _activateTrial({ planId }) { | 234 | @action async _activateTrial({ planId }) { |
@@ -250,9 +244,6 @@ export default class UserStore extends Store { | |||
250 | 244 | ||
251 | this.stores.features.featuresRequest.invalidate({ immediately: true }); | 245 | this.stores.features.featuresRequest.invalidate({ immediately: true }); |
252 | this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); | 246 | this.stores.user.getUserInfoRequest.invalidate({ immediately: true }); |
253 | |||
254 | |||
255 | gaEvent('User', 'activateTrial'); | ||
256 | } | 247 | } |
257 | 248 | ||
258 | @action async _invite({ invites }) { | 249 | @action async _invite({ invites }) { |
@@ -266,8 +257,6 @@ export default class UserStore extends Store { | |||
266 | if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) { | 257 | if (this.stores.router.location.pathname.includes(this.INVITE_ROUTE)) { |
267 | this.stores.router.push('/'); | 258 | this.stores.router.push('/'); |
268 | } | 259 | } |
269 | |||
270 | gaEvent('User', 'inviteUsers'); | ||
271 | } | 260 | } |
272 | 261 | ||
273 | @action async _update({ userData }) { | 262 | @action async _update({ userData }) { |
@@ -277,8 +266,6 @@ export default class UserStore extends Store { | |||
277 | 266 | ||
278 | this.getUserInfoRequest.patch(() => response.data); | 267 | this.getUserInfoRequest.patch(() => response.data); |
279 | this.actionStatus = response.status || []; | 268 | this.actionStatus = response.status || []; |
280 | |||
281 | gaEvent('User', 'update'); | ||
282 | } | 269 | } |
283 | 270 | ||
284 | @action _resetStatus() { | 271 | @action _resetStatus() { |
@@ -301,12 +288,12 @@ export default class UserStore extends Store { | |||
301 | const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id); | 288 | const recipes = services.filter((obj, pos, arr) => arr.map(mapObj => mapObj.recipe.id).indexOf(obj.recipe.id) === pos).map(s => s.recipe.id); |
302 | 289 | ||
303 | // Install recipes | 290 | // Install recipes |
304 | for (const recipe of recipes) { | 291 | for (const recipe of recipes) { // eslint-disable-line no-unused-vars |
305 | // eslint-disable-next-line | 292 | // eslint-disable-next-line |
306 | await this.stores.recipes._install({ recipeId: recipe }); | 293 | await this.stores.recipes._install({ recipeId: recipe }); |
307 | } | 294 | } |
308 | 295 | ||
309 | for (const service of services) { | 296 | for (const service of services) { // eslint-disable-line no-unused-vars |
310 | this.actions.service.createFromLegacyService({ | 297 | this.actions.service.createFromLegacyService({ |
311 | data: service, | 298 | data: service, |
312 | }); | 299 | }); |