diff options
Diffstat (limited to 'src/components/ui')
-rw-r--r-- | src/components/ui/PremiumFeatureContainer/index.js | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/components/ui/PremiumFeatureContainer/index.js b/src/components/ui/PremiumFeatureContainer/index.js index 113fe2221..73984be94 100644 --- a/src/components/ui/PremiumFeatureContainer/index.js +++ b/src/components/ui/PremiumFeatureContainer/index.js | |||
@@ -6,6 +6,8 @@ import injectSheet from 'react-jss'; | |||
6 | 6 | ||
7 | import { oneOrManyChildElements } from '../../../prop-types'; | 7 | import { oneOrManyChildElements } from '../../../prop-types'; |
8 | 8 | ||
9 | import UserStore from '../../../stores/UserStore'; | ||
10 | |||
9 | import styles from './styles'; | 11 | import styles from './styles'; |
10 | 12 | ||
11 | const messages = defineMessages({ | 13 | const messages = defineMessages({ |
@@ -15,9 +17,14 @@ const messages = defineMessages({ | |||
15 | }, | 17 | }, |
16 | }); | 18 | }); |
17 | 19 | ||
18 | export default @inject('actions') @injectSheet(styles) @observer class PremiumFeatureContainer extends Component { | 20 | export default @inject('stores', 'actions') @injectSheet(styles) @observer class PremiumFeatureContainer extends Component { |
19 | static propTypes = { | 21 | static propTypes = { |
20 | classes: PropTypes.object.isRequired, | 22 | classes: PropTypes.object.isRequired, |
23 | condition: PropTypes.bool, | ||
24 | }; | ||
25 | |||
26 | static defaultProps = { | ||
27 | condition: true, | ||
21 | }; | 28 | }; |
22 | 29 | ||
23 | static contextTypes = { | 30 | static contextTypes = { |
@@ -29,11 +36,13 @@ export default @inject('actions') @injectSheet(styles) @observer class PremiumFe | |||
29 | classes, | 36 | classes, |
30 | children, | 37 | children, |
31 | actions, | 38 | actions, |
39 | condition, | ||
40 | stores, | ||
32 | } = this.props; | 41 | } = this.props; |
33 | 42 | ||
34 | const { intl } = this.context; | 43 | const { intl } = this.context; |
35 | 44 | ||
36 | return ( | 45 | return !stores.user.data.isPremium && !!condition ? ( |
37 | <div className={classes.container}> | 46 | <div className={classes.container}> |
38 | <div className={classes.titleContainer}> | 47 | <div className={classes.titleContainer}> |
39 | <p className={classes.title}>Premium Feature</p> | 48 | <p className={classes.title}>Premium Feature</p> |
@@ -49,12 +58,15 @@ export default @inject('actions') @injectSheet(styles) @observer class PremiumFe | |||
49 | {children} | 58 | {children} |
50 | </div> | 59 | </div> |
51 | </div> | 60 | </div> |
52 | ); | 61 | ) : children; |
53 | } | 62 | } |
54 | } | 63 | } |
55 | 64 | ||
56 | PremiumFeatureContainer.wrappedComponent.propTypes = { | 65 | PremiumFeatureContainer.wrappedComponent.propTypes = { |
57 | children: oneOrManyChildElements.isRequired, | 66 | children: oneOrManyChildElements.isRequired, |
67 | stores: PropTypes.shape({ | ||
68 | user: PropTypes.instanceOf(UserStore).isRequired, | ||
69 | }).isRequired, | ||
58 | actions: PropTypes.shape({ | 70 | actions: PropTypes.shape({ |
59 | ui: PropTypes.shape({ | 71 | ui: PropTypes.shape({ |
60 | openSettings: PropTypes.func.isRequired, | 72 | openSettings: PropTypes.func.isRequired, |