diff options
Diffstat (limited to 'src/helpers/plan-helpers.js')
-rw-r--r-- | src/helpers/plan-helpers.js | 53 |
1 files changed, 0 insertions, 53 deletions
diff --git a/src/helpers/plan-helpers.js b/src/helpers/plan-helpers.js deleted file mode 100644 index b474f8bbd..000000000 --- a/src/helpers/plan-helpers.js +++ /dev/null | |||
@@ -1,53 +0,0 @@ | |||
1 | import { defineMessages } from 'react-intl'; | ||
2 | import { PLANS_MAPPING, PLANS } from '../config'; | ||
3 | |||
4 | const messages = defineMessages({ | ||
5 | [PLANS.PRO]: { | ||
6 | id: 'pricing.plan.pro', | ||
7 | defaultMessage: '!!!Professional', | ||
8 | }, | ||
9 | [PLANS.PERSONAL]: { | ||
10 | id: 'pricing.plan.personal', | ||
11 | defaultMessage: '!!!Personal', | ||
12 | }, | ||
13 | [PLANS.FREE]: { | ||
14 | id: 'pricing.plan.free', | ||
15 | defaultMessage: '!!!Free', | ||
16 | }, | ||
17 | [PLANS.LEGACY]: { | ||
18 | id: 'pricing.plan.legacy', | ||
19 | defaultMessage: '!!!Premium', | ||
20 | }, | ||
21 | }); | ||
22 | |||
23 | export function cleanupPlanId(id) { | ||
24 | return id.replace(/(.*)-x[0-9]/, '$1'); | ||
25 | } | ||
26 | |||
27 | export function i18nPlanName(planId, intl) { | ||
28 | if (!planId) { | ||
29 | throw new Error('planId is required'); | ||
30 | } | ||
31 | |||
32 | if (!intl) { | ||
33 | throw new Error('intl context is required'); | ||
34 | } | ||
35 | |||
36 | const id = cleanupPlanId(planId); | ||
37 | |||
38 | const plan = PLANS_MAPPING[id]; | ||
39 | |||
40 | return intl.formatMessage(messages[plan]); | ||
41 | } | ||
42 | |||
43 | export function getPlan(planId) { | ||
44 | if (!planId) { | ||
45 | throw new Error('planId is required'); | ||
46 | } | ||
47 | |||
48 | const id = cleanupPlanId(planId); | ||
49 | |||
50 | const plan = PLANS_MAPPING[id]; | ||
51 | |||
52 | return plan; | ||
53 | } | ||