mirror of
https://github.com/logto-io/logto.git
synced 2025-03-10 22:22:45 -05:00
fix(core): fix the subscription api response type (#6834)
fix the subscription api response type all dates value should be converted to ISO 8601 string
This commit is contained in:
parent
2178589507
commit
8a15a60c37
2 changed files with 20 additions and 2 deletions
|
@ -16,7 +16,15 @@ export const getTenantSubscription = async (
|
||||||
const client = await cloudConnection.getClient();
|
const client = await cloudConnection.getClient();
|
||||||
const subscription = await client.get('/api/tenants/my/subscription');
|
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 (
|
export const getTenantSubscriptionData = async (
|
||||||
|
|
|
@ -10,7 +10,17 @@ type RouteResponseType<T extends { search?: unknown; body?: unknown; response?:
|
||||||
type RouteRequestBodyType<T extends { search?: unknown; body?: ZodType; response?: unknown }> =
|
type RouteRequestBodyType<T extends { search?: unknown; body?: ZodType; response?: unknown }> =
|
||||||
z.infer<NonNullable<T['body']>>;
|
z.infer<NonNullable<T['body']>>;
|
||||||
|
|
||||||
export type Subscription = RouteResponseType<GetRoutes['/api/tenants/my/subscription']>;
|
/**
|
||||||
|
* 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<GetRoutes['/api/tenants/my/subscription']>,
|
||||||
|
'currentPeriodStart' | 'currentPeriodEnd'
|
||||||
|
> & {
|
||||||
|
currentPeriodStart: string;
|
||||||
|
currentPeriodEnd: string;
|
||||||
|
};
|
||||||
|
|
||||||
type CompleteSubscriptionUsage = RouteResponseType<GetRoutes['/api/tenants/my/subscription-usage']>;
|
type CompleteSubscriptionUsage = RouteResponseType<GetRoutes['/api/tenants/my/subscription-usage']>;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue