mirror of
https://github.com/logto-io/logto.git
synced 2024-12-16 20:26:19 -05:00
refactor(console): replace get sku api (#6861)
replace the `api/sku` API using `api/tenants/:tenantId/available-sku
This commit is contained in:
parent
d2fb597ef3
commit
51c9c52a61
1 changed files with 6 additions and 3 deletions
|
@ -1,5 +1,5 @@
|
|||
import { type Optional } from '@silverhand/essentials';
|
||||
import { useMemo } from 'react';
|
||||
import { useContext, useMemo } from 'react';
|
||||
import useSWRImmutable from 'swr/immutable';
|
||||
|
||||
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
|
||||
|
@ -9,6 +9,7 @@ import { featuredPlanIdOrder } from '@/consts/subscriptions';
|
|||
// Used in the docs
|
||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||
import TenantAccess from '@/containers/TenantAccess';
|
||||
import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||
import { LogtoSkuType } from '@/types/skus';
|
||||
import { sortBy } from '@/utils/sort';
|
||||
import { addSupportQuota } from '@/utils/subscription';
|
||||
|
@ -19,11 +20,13 @@ import { addSupportQuota } from '@/utils/subscription';
|
|||
*/
|
||||
const useLogtoSkus = () => {
|
||||
const cloudApi = useCloudApi();
|
||||
const { currentTenantId } = useContext(TenantsContext);
|
||||
|
||||
const useSwrResponse = useSWRImmutable<LogtoSkuResponse[], Error>(
|
||||
isCloud && '/api/skus',
|
||||
isCloud && currentTenantId && `/api/tenants/${currentTenantId}/available-skus`,
|
||||
async () =>
|
||||
cloudApi.get('/api/skus', {
|
||||
cloudApi.get('/api/tenants/:tenantId/available-skus', {
|
||||
params: { tenantId: currentTenantId },
|
||||
search: { type: LogtoSkuType.Basic },
|
||||
})
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue