aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/serviceLimit
diff options
context:
space:
mode:
Diffstat (limited to 'src/features/serviceLimit')
-rw-r--r--src/features/serviceLimit/components/LimitReachedInfobox.js75
-rw-r--r--src/features/serviceLimit/index.js31
-rw-r--r--src/features/serviceLimit/store.js42
3 files changed, 0 insertions, 148 deletions
diff --git a/src/features/serviceLimit/components/LimitReachedInfobox.js b/src/features/serviceLimit/components/LimitReachedInfobox.js
deleted file mode 100644
index 424c92990..000000000
--- a/src/features/serviceLimit/components/LimitReachedInfobox.js
+++ /dev/null
@@ -1,75 +0,0 @@
1import React, { Component } from 'react';
2import PropTypes from 'prop-types';
3import { inject, observer } from 'mobx-react';
4import { defineMessages, intlShape } from 'react-intl';
5import injectSheet from 'react-jss';
6import { Infobox } from '@meetfranz/ui';
7
8const messages = defineMessages({
9 limitReached: {
10 id: 'feature.serviceLimit.limitReached',
11 defaultMessage: '!!!You have added {amount} of {limit} services. Please upgrade your account to add more services.',
12 },
13 action: {
14 id: 'premiumFeature.button.upgradeAccount',
15 defaultMessage: '!!!Upgrade account',
16 },
17});
18
19const styles = theme => ({
20 container: {
21 height: 'auto',
22 background: theme.styleTypes.warning.accent,
23 color: theme.styleTypes.warning.contrast,
24 borderRadius: 0,
25 marginBottom: 0,
26
27 '& > div': {
28 marginBottom: 0,
29 },
30
31 '& button': {
32 color: theme.styleTypes.primary.contrast,
33 },
34 },
35});
36
37@inject('stores', 'actions') @injectSheet(styles) @observer
38class LimitReachedInfobox extends Component {
39 static propTypes = {
40 classes: PropTypes.object.isRequired,
41 stores: PropTypes.object.isRequired,
42 actions: PropTypes.object.isRequired,
43 };
44
45 static contextTypes = {
46 intl: intlShape,
47 };
48
49 render() {
50 const { classes, stores, actions } = this.props;
51 const { intl } = this.context;
52
53 const {
54 serviceLimit,
55 } = stores;
56
57 if (!serviceLimit.userHasReachedServiceLimit) return null;
58
59 return (
60 <Infobox
61 icon="mdiInformation"
62 type="warning"
63 className={classes.container}
64 ctaLabel={intl.formatMessage(messages.action)}
65 ctaOnClick={() => {
66 actions.ui.openSettings({ path: 'user' });
67 }}
68 >
69 {intl.formatMessage(messages.limitReached, { amount: serviceLimit.serviceCount, limit: serviceLimit.serviceLimit })}
70 </Infobox>
71 );
72 }
73}
74
75export default LimitReachedInfobox;
diff --git a/src/features/serviceLimit/index.js b/src/features/serviceLimit/index.js
deleted file mode 100644
index f867e3d87..000000000
--- a/src/features/serviceLimit/index.js
+++ /dev/null
@@ -1,31 +0,0 @@
1import { reaction } from 'mobx';
2import { ServiceLimitStore } from './store';
3
4const debug = require('debug')('Ferdi:feature:serviceLimit');
5
6let store = null;
7
8export const serviceLimitStore = new ServiceLimitStore();
9
10export default function initServiceLimit(stores, actions) {
11 const { features } = stores;
12
13 // Toggle serviceLimit feature
14 reaction(
15 () => (
16 features.features.isServiceLimitEnabled
17 ),
18 (isEnabled) => {
19 if (isEnabled) {
20 debug('Initializing `serviceLimit` feature');
21 store = serviceLimitStore.start(stores, actions);
22 } else if (store) {
23 debug('Disabling `serviceLimit` feature');
24 serviceLimitStore.stop();
25 }
26 },
27 {
28 fireImmediately: true,
29 },
30 );
31}
diff --git a/src/features/serviceLimit/store.js b/src/features/serviceLimit/store.js
deleted file mode 100644
index b1e55a1fc..000000000
--- a/src/features/serviceLimit/store.js
+++ /dev/null
@@ -1,42 +0,0 @@
1import { computed, observable } from 'mobx';
2import { FeatureStore } from '../utils/FeatureStore';
3import { DEFAULT_SERVICE_LIMIT } from '../../config';
4
5const debug = require('debug')('Ferdi:feature:serviceLimit:store');
6
7export class ServiceLimitStore extends FeatureStore {
8 @observable isServiceLimitEnabled = false;
9
10 start(stores, actions) {
11 debug('start');
12 this.stores = stores;
13 this.actions = actions;
14
15 this.isServiceLimitEnabled = false;
16 }
17
18 stop() {
19 super.stop();
20
21 this.isServiceLimitEnabled = false;
22 }
23
24 @computed get userHasReachedServiceLimit() {
25 return false;
26 // if (!this.isServiceLimitEnabled) return false;
27
28 // return this.serviceLimit !== 0 && this.serviceCount >= this.serviceLimit;
29 }
30
31 @computed get serviceLimit() {
32 if (!this.isServiceLimitEnabled || this.stores.features.features.serviceLimitCount === 0) return 0;
33
34 return this.stores.features.features.serviceLimitCount || DEFAULT_SERVICE_LIMIT;
35 }
36
37 @computed get serviceCount() {
38 return this.stores.services.all.length;
39 }
40}
41
42export default ServiceLimitStore;