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 { type Optional } from '@silverhand/essentials';
|
||||||
import { useMemo } from 'react';
|
import { useContext, useMemo } from 'react';
|
||||||
import useSWRImmutable from 'swr/immutable';
|
import useSWRImmutable from 'swr/immutable';
|
||||||
|
|
||||||
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
|
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
|
||||||
|
@ -9,6 +9,7 @@ import { featuredPlanIdOrder } from '@/consts/subscriptions';
|
||||||
// Used in the docs
|
// Used in the docs
|
||||||
// eslint-disable-next-line unused-imports/no-unused-imports
|
// eslint-disable-next-line unused-imports/no-unused-imports
|
||||||
import TenantAccess from '@/containers/TenantAccess';
|
import TenantAccess from '@/containers/TenantAccess';
|
||||||
|
import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||||
import { LogtoSkuType } from '@/types/skus';
|
import { LogtoSkuType } from '@/types/skus';
|
||||||
import { sortBy } from '@/utils/sort';
|
import { sortBy } from '@/utils/sort';
|
||||||
import { addSupportQuota } from '@/utils/subscription';
|
import { addSupportQuota } from '@/utils/subscription';
|
||||||
|
@ -19,11 +20,13 @@ import { addSupportQuota } from '@/utils/subscription';
|
||||||
*/
|
*/
|
||||||
const useLogtoSkus = () => {
|
const useLogtoSkus = () => {
|
||||||
const cloudApi = useCloudApi();
|
const cloudApi = useCloudApi();
|
||||||
|
const { currentTenantId } = useContext(TenantsContext);
|
||||||
|
|
||||||
const useSwrResponse = useSWRImmutable<LogtoSkuResponse[], Error>(
|
const useSwrResponse = useSWRImmutable<LogtoSkuResponse[], Error>(
|
||||||
isCloud && '/api/skus',
|
isCloud && currentTenantId && `/api/tenants/${currentTenantId}/available-skus`,
|
||||||
async () =>
|
async () =>
|
||||||
cloudApi.get('/api/skus', {
|
cloudApi.get('/api/tenants/:tenantId/available-skus', {
|
||||||
|
params: { tenantId: currentTenantId },
|
||||||
search: { type: LogtoSkuType.Basic },
|
search: { type: LogtoSkuType.Basic },
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in a new issue