From 76559f2895012803aed3256ce521b9cfff2f63b8 Mon Sep 17 00:00:00 2001 From: Stefan Malzner Date: Mon, 5 Aug 2019 13:24:35 +0200 Subject: WIP: add option to activate trial --- src/features/delayApp/Component.js | 43 ++++++++++++++++++++++++++++++-------- src/features/delayApp/index.js | 2 +- 2 files changed, 35 insertions(+), 10 deletions(-) (limited to 'src/features/delayApp') diff --git a/src/features/delayApp/Component.js b/src/features/delayApp/Component.js index ff0f1f2f8..de5653f04 100644 --- a/src/features/delayApp/Component.js +++ b/src/features/delayApp/Component.js @@ -4,29 +4,39 @@ import { inject, observer } from 'mobx-react'; import { defineMessages, intlShape } from 'react-intl'; import injectSheet from 'react-jss'; +import { Button } from '@meetfranz/forms'; import { gaEvent } from '../../lib/analytics'; -import Button from '../../components/ui/Button'; +// import Button from '../../components/ui/Button'; import { config } from '.'; import styles from './styles'; +import UserStore from '../../stores/UserStore'; const messages = defineMessages({ headline: { id: 'feature.delayApp.headline', defaultMessage: '!!!Please purchase license to skip waiting', }, + headlineTrial: { + id: 'feature.delayApp.trial.headline', + defaultMessage: '!!!Get the free Franz Professional 14 day trial and skip the line', + }, action: { - id: 'feature.delayApp.action', + id: 'feature.delayApp.upgrade.action', defaultMessage: '!!!Get a Franz Supporter License', }, + actionTrial: { + id: 'feature.delayApp.trial.action', + defaultMessage: '!!!Yes, I want the free 14 day trial of Franz Professional', + }, text: { id: 'feature.delayApp.text', defaultMessage: '!!!Franz will continue in {seconds} seconds.', }, }); -export default @inject('actions') @injectSheet(styles) @observer class DelayApp extends Component { +export default @inject('stores', 'actions') @injectSheet(styles) @observer class DelayApp extends Component { static propTypes = { // eslint-disable-next-line classes: PropTypes.object.isRequired, @@ -62,25 +72,37 @@ export default @inject('actions') @injectSheet(styles) @observer class DelayApp } handleCTAClick() { - const { actions } = this.props; + const { actions, stores } = this.props; + const { hadSubscription } = stores.user.data; + const { defaultTrialPlan } = stores.features.features; + + if (!hadSubscription) { + console.log('directly activate trial'); + actions.user.activateTrial({ planId: defaultTrialPlan }); - actions.ui.openSettings({ path: 'user' }); + gaEvent('DelayApp', 'subscribe_click', 'Delay App Feature'); + } else { + actions.ui.openSettings({ path: 'user' }); - gaEvent('DelayApp', 'subscribe_click', 'Delay App Feature'); + gaEvent('DelayApp', 'subscribe_click', 'Delay App Feature'); + } } render() { - const { classes } = this.props; + const { classes, stores } = this.props; const { intl } = this.context; + const { hadSubscription } = stores.user.data; + return (
-

{intl.formatMessage(messages.headline)}

+

{intl.formatMessage(hadSubscription ? messages.headline : messages.headlineTrial)}