aboutsummaryrefslogtreecommitdiffstats
path: root/src/helpers/plan-helpers.js
blob: 37a4457afbf2374f425216f038af0151a8fa9496 (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
43
import { defineMessages } from 'react-intl';
import { PLANS_MAPPING, PLANS } from '../config';

const messages = defineMessages({
  [PLANS.PRO_YEARLY]: {
    id: 'pricing.plan.pro-yearly',
    defaultMessage: '!!!Franz Professional Yearly',
  },
  [PLANS.PRO_MONTHLY]: {
    id: 'pricing.plan.pro-monthly',
    defaultMessage: '!!!Franz Professional Monthly',
  },
  [PLANS.PERSONAL_YEARLY]: {
    id: 'pricing.plan.personal-yearly',
    defaultMessage: '!!!Franz Personal Yearly',
  },
  [PLANS.PERSONAL_MONTHLY]: {
    id: 'pricing.plan.personal-monthly',
    defaultMessage: '!!!Franz Personal Monthly',
  },
  [PLANS.FREE]: {
    id: 'pricing.plan.free',
    defaultMessage: '!!!Franz Free',
  },
  [PLANS.LEGACY]: {
    id: 'pricing.plan.legacy',
    defaultMessage: '!!!Franz Premium',
  },
});

export function i18nPlanName(planId, intl) {
  if (!planId) {
    throw new Error('planId is required');
  }

  if (!intl) {
    throw new Error('intl context is required');
  }

  const plan = PLANS_MAPPING[planId];

  return intl.formatMessage(messages[plan]);
}