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,
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;