Merge branch 'IDTEAM-1.26.0' into 'main'
[ProtonMail-WebClient.git] / packages / pass / lib / user / user.plan.ts
blob2be7113c72a56752bc919e59a45bc69ca1674401
1 import { type MaybeNull, type PassPlanResponse, PlanType } from '@proton/pass/types';
2 import { UserPassPlan } from '@proton/pass/types/api/plan';
3 import { getEpoch } from '@proton/pass/utils/time/epoch';
5 export const getPassPlan = (plan?: MaybeNull<PassPlanResponse>): UserPassPlan => {
6     switch (plan?.Type) {
7         case PlanType.plus:
8             return plan.TrialEnd && getEpoch() < plan.TrialEnd ? UserPassPlan.TRIAL : UserPassPlan.PLUS;
9         case PlanType.business:
10             return UserPassPlan.BUSINESS;
11         default: {
12             return UserPassPlan.FREE;
13         }
14     }