aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/ui/PremiumFeatureContainer
diff options
context:
space:
mode:
authorLibravatar vantezzen <properly@protonmail.com>2019-09-07 15:50:23 +0200
committerLibravatar vantezzen <properly@protonmail.com>2019-09-07 15:50:23 +0200
commite7a74514c1e7c3833dfdcf5900cb87f9e6e8354e (patch)
treeb8314e4155503b135dcb07e8b4a0e847e25c19cf /src/components/ui/PremiumFeatureContainer
parentUpdate CHANGELOG.md (diff)
parentUpdate CHANGELOG.md (diff)
downloadferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.tar.gz
ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.tar.zst
ferdium-app-e7a74514c1e7c3833dfdcf5900cb87f9e6e8354e.zip
Merge branch 'master' of https://github.com/meetfranz/franz into franz-5.3.0
Diffstat (limited to 'src/components/ui/PremiumFeatureContainer')
-rw-r--r--src/components/ui/PremiumFeatureContainer/index.js22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/components/ui/PremiumFeatureContainer/index.js b/src/components/ui/PremiumFeatureContainer/index.js
index b890b09ab..c53d345a0 100644
--- a/src/components/ui/PremiumFeatureContainer/index.js
+++ b/src/components/ui/PremiumFeatureContainer/index.js
@@ -9,6 +9,7 @@ import { oneOrManyChildElements } from '../../../prop-types';
9import UserStore from '../../../stores/UserStore'; 9import UserStore from '../../../stores/UserStore';
10 10
11import styles from './styles'; 11import styles from './styles';
12import { FeatureStore } from '../../../features/utils/FeatureStore';
12 13
13const messages = defineMessages({ 14const messages = defineMessages({
14 action: { 15 action: {
@@ -21,7 +22,10 @@ const messages = defineMessages({
21class PremiumFeatureContainer extends Component { 22class PremiumFeatureContainer extends Component {
22 static propTypes = { 23 static propTypes = {
23 classes: PropTypes.object.isRequired, 24 classes: PropTypes.object.isRequired,
24 condition: PropTypes.bool, 25 condition: PropTypes.oneOfType([
26 PropTypes.bool,
27 PropTypes.func,
28 ]),
25 gaEventInfo: PropTypes.shape({ 29 gaEventInfo: PropTypes.shape({
26 category: PropTypes.string.isRequired, 30 category: PropTypes.string.isRequired,
27 event: PropTypes.string.isRequired, 31 event: PropTypes.string.isRequired,
@@ -30,7 +34,7 @@ class PremiumFeatureContainer extends Component {
30 }; 34 };
31 35
32 static defaultProps = { 36 static defaultProps = {
33 condition: true, 37 condition: null,
34 gaEventInfo: null, 38 gaEventInfo: null,
35 }; 39 };
36 40
@@ -49,7 +53,18 @@ class PremiumFeatureContainer extends Component {
49 53
50 const { intl } = this.context; 54 const { intl } = this.context;
51 55
52 return !stores.user.data.isPremium && !!condition ? ( 56 let showWrapper = !!condition;
57
58 if (condition === null) {
59 showWrapper = !stores.user.data.isPremium;
60 } else if (typeof condition === 'function') {
61 showWrapper = condition({
62 isPremium: stores.user.data.isPremium,
63 features: stores.features.features,
64 });
65 }
66
67 return showWrapper ? (
53 <div className={classes.container}> 68 <div className={classes.container}>
54 <div className={classes.titleContainer}> 69 <div className={classes.titleContainer}>
55 <p className={classes.title}>Premium Feature</p> 70 <p className={classes.title}>Premium Feature</p>
@@ -75,6 +90,7 @@ PremiumFeatureContainer.wrappedComponent.propTypes = {
75 children: oneOrManyChildElements.isRequired, 90 children: oneOrManyChildElements.isRequired,
76 stores: PropTypes.shape({ 91 stores: PropTypes.shape({
77 user: PropTypes.instanceOf(UserStore).isRequired, 92 user: PropTypes.instanceOf(UserStore).isRequired,
93 features: PropTypes.instanceOf(FeatureStore).isRequired,
78 }).isRequired, 94 }).isRequired,
79 actions: PropTypes.shape({ 95 actions: PropTypes.shape({
80 ui: PropTypes.shape({ 96 ui: PropTypes.shape({