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