Cleanup - unused files / unused exports / duplicate exports
[ProtonMail-WebClient.git] / packages / components / containers / payments / helper.ts
bloba909647b6151170b92e5a501bb6aeeb24d4af6a6
1 import { type PlanIDs } from '@proton/payments';
2 import type { CYCLE } from '@proton/shared/lib/constants';
3 import isDeepEqual from '@proton/shared/lib/helpers/isDeepEqual';
4 import { getPlanIDs } from '@proton/shared/lib/helpers/subscription';
5 import type { Subscription } from '@proton/shared/lib/interfaces';
7 export function isSubscriptionUnchanged(
8     subscription: Subscription | null | undefined,
9     planIds: PlanIDs,
10     cycle?: CYCLE
11 ): boolean {
12     const subscriptionPlanIds = getPlanIDs(subscription);
14     const planIdsUnchanged = isDeepEqual(subscriptionPlanIds, planIds);
15     // Cycle is optional, so if it is not provided, we assume it is unchanged
16     const cycleUnchanged =
17         !cycle || cycle === subscription?.Cycle || cycle === subscription?.UpcomingSubscription?.Cycle;
19     return planIdsUnchanged && cycleUnchanged;