11import type { Organization } from './account/organization' ;
22import type { Subscription } from './account/subscription' ;
33import {
4- computeSubscriptionState ,
54 getSubscriptionPlan ,
65 getSubscriptionPlanPriority ,
6+ isSubscriptionExpired ,
77 SubscriptionPlanId ,
8- SubscriptionState ,
98} from './account/subscription' ;
109
1110export interface GKCheckInResponse {
@@ -72,7 +71,6 @@ export function getSubscriptionFromCheckIn(
7271
7372 let effectiveLicenses = Object . entries ( data . licenses . effectiveLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
7473 let paidLicenses = Object . entries ( data . licenses . paidLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
75- paidLicenses = paidLicenses . filter ( license => license [ 1 ] . latestStatus !== 'cancelled' ) ;
7674 if ( paidLicenses . length > 1 ) {
7775 paidLicenses . sort (
7876 ( a , b ) =>
@@ -82,6 +80,7 @@ export function getSubscriptionFromCheckIn(
8280 licenseStatusPriority ( a [ 1 ] . latestStatus ) ) ,
8381 ) ;
8482 }
83+
8584 if ( effectiveLicenses . length > 1 ) {
8685 effectiveLicenses . sort (
8786 ( a , b ) =>
@@ -180,17 +179,10 @@ export function getSubscriptionFromCheckIn(
180179 ) ;
181180 }
182181
183- const isActualLicenseExpired =
184- computeSubscriptionState ( {
185- plan : {
186- actual : actual ,
187- effective : actual ,
188- } ,
189- account : account ,
190- } ) === SubscriptionState . PaidExpired ;
191182 if (
192183 effective == null ||
193- ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) && ! isActualLicenseExpired )
184+ ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) &&
185+ ! isSubscriptionExpired ( actual ) )
194186 ) {
195187 effective = { ...actual } ;
196188 }
0 commit comments