aboutsummaryrefslogtreecommitdiffstats
path: root/src/features/serviceLimit/store.js
blob: 6510e28724571f0899d1daf93937e1c4b85b1c27 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import { computed, observable } from 'mobx';
import { FeatureStore } from '../utils/FeatureStore';
import { DEFAULT_SERVICE_LIMIT } from '.';

const debug = require('debug')('Ferdi:feature:serviceLimit:store');

export class ServiceLimitStore extends FeatureStore {
  @observable isServiceLimitEnabled = false;

  start(stores, actions) {
    debug('start');
    this.stores = stores;
    this.actions = actions;

    this.isServiceLimitEnabled = false;
  }

  stop() {
    super.stop();

    this.isServiceLimitEnabled = false;
  }

  @computed get userHasReachedServiceLimit() {
    return false;
    // if (!this.isServiceLimitEnabled) return false;

    // return this.serviceLimit !== 0 && this.serviceCount >= this.serviceLimit;
  }

  @computed get serviceLimit() {
    if (!this.isServiceLimitEnabled || this.stores.features.features.serviceLimitCount === 0) return 0;

    return this.stores.features.features.serviceLimitCount || DEFAULT_SERVICE_LIMIT;
  }

  @computed get serviceCount() {
    return this.stores.services.all.length;
  }
}

export default ServiceLimitStore;