1
1
import type { Organization } from './account/organization' ;
2
2
import type { Subscription } from './account/subscription' ;
3
3
import {
4
- computeSubscriptionState ,
5
4
getSubscriptionPlan ,
6
5
getSubscriptionPlanPriority ,
6
+ isSubscriptionExpired ,
7
7
SubscriptionPlanId ,
8
- SubscriptionState ,
9
8
} from './account/subscription' ;
10
9
11
10
export interface GKCheckInResponse {
@@ -72,7 +71,6 @@ export function getSubscriptionFromCheckIn(
72
71
73
72
let effectiveLicenses = Object . entries ( data . licenses . effectiveLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
74
73
let paidLicenses = Object . entries ( data . licenses . paidLicenses ) as [ GKLicenseType , GKLicense ] [ ] ;
75
- paidLicenses = paidLicenses . filter ( license => license [ 1 ] . latestStatus !== 'cancelled' ) ;
76
74
if ( paidLicenses . length > 1 ) {
77
75
paidLicenses . sort (
78
76
( a , b ) =>
@@ -82,6 +80,7 @@ export function getSubscriptionFromCheckIn(
82
80
licenseStatusPriority ( a [ 1 ] . latestStatus ) ) ,
83
81
) ;
84
82
}
83
+
85
84
if ( effectiveLicenses . length > 1 ) {
86
85
effectiveLicenses . sort (
87
86
( a , b ) =>
@@ -180,17 +179,10 @@ export function getSubscriptionFromCheckIn(
180
179
) ;
181
180
}
182
181
183
- const isActualLicenseExpired =
184
- computeSubscriptionState ( {
185
- plan : {
186
- actual : actual ,
187
- effective : actual ,
188
- } ,
189
- account : account ,
190
- } ) === SubscriptionState . PaidExpired ;
191
182
if (
192
183
effective == null ||
193
- ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) && ! isActualLicenseExpired )
184
+ ( getSubscriptionPlanPriority ( actual . id ) >= getSubscriptionPlanPriority ( effective . id ) &&
185
+ ! isSubscriptionExpired ( actual ) )
194
186
) {
195
187
effective = { ...actual } ;
196
188
}
0 commit comments