planDetailsLookup.ts 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import cloneDeep from 'lodash/cloneDeep';
  2. import AM1_PLANS from 'getsentry-test/fixtures/am1Plans';
  3. import AM2_PLANS from 'getsentry-test/fixtures/am2Plans';
  4. import AM3_PLANS from 'getsentry-test/fixtures/am3Plans';
  5. import MM1_PLANS from 'getsentry-test/fixtures/mm1Plans';
  6. import MM2_PLANS from 'getsentry-test/fixtures/mm2Plans';
  7. import {PlanTier} from 'getsentry/types';
  8. type PlanIds = keyof typeof AM1_PLANS &
  9. keyof typeof AM2_PLANS &
  10. keyof typeof AM3_PLANS &
  11. keyof typeof MM1_PLANS &
  12. keyof typeof MM2_PLANS;
  13. // Pass a planId to get back details for that particular plan, or 'all'
  14. // to get a list of all plan detail objects for a plan tier.
  15. export function PlanDetailsLookupFixture(planId: PlanIds, tier?: PlanTier) {
  16. if (!planId) {
  17. throw new Error('Must provide a planId or `all`');
  18. }
  19. const planData =
  20. tier ?? planId.startsWith(PlanTier.AM3)
  21. ? AM3_PLANS[planId]
  22. : planId.startsWith(PlanTier.AM1)
  23. ? AM1_PLANS[planId]
  24. : planId.startsWith(PlanTier.AM2)
  25. ? AM2_PLANS[planId]
  26. : planId.startsWith(PlanTier.MM2)
  27. ? MM2_PLANS[planId]
  28. : MM1_PLANS[planId];
  29. return cloneDeep(planData);
  30. }