diff --git a/packages/core/src/utils/subscription/index.ts b/packages/core/src/utils/subscription/index.ts index 97fb290b2..c167b1119 100644 --- a/packages/core/src/utils/subscription/index.ts +++ b/packages/core/src/utils/subscription/index.ts @@ -16,7 +16,15 @@ export const getTenantSubscription = async ( const client = await cloudConnection.getClient(); const subscription = await client.get('/api/tenants/my/subscription'); - return subscription; + // All the dates will be converted to the ISO 8601 format after json serialization. + // Convert the dates to ISO 8601 format to match the exact type of the response. + const { currentPeriodStart, currentPeriodEnd, ...rest } = subscription; + + return { + ...rest, + currentPeriodStart: new Date(currentPeriodStart).toISOString(), + currentPeriodEnd: new Date(currentPeriodEnd).toISOString(), + }; }; export const getTenantSubscriptionData = async ( diff --git a/packages/core/src/utils/subscription/types.ts b/packages/core/src/utils/subscription/types.ts index 55f1353fc..9b3ee9a6d 100644 --- a/packages/core/src/utils/subscription/types.ts +++ b/packages/core/src/utils/subscription/types.ts @@ -10,7 +10,17 @@ type RouteResponseType = z.infer>; -export type Subscription = RouteResponseType; +/** + * The subscription data is fetched from the Cloud API. + * All the dates are in ISO 8601 format, we need to manually fix the type to string here. + */ +export type Subscription = Omit< + RouteResponseType, + 'currentPeriodStart' | 'currentPeriodEnd' +> & { + currentPeriodStart: string; + currentPeriodEnd: string; +}; type CompleteSubscriptionUsage = RouteResponseType;