Skip to content

Commit

Permalink
refactor(console): replace get sku api (logto-io#6861)
Browse files Browse the repository at this point in the history
replace the `api/sku` API using `api/tenants/:tenantId/available-sku
  • Loading branch information
simeng-li authored Dec 9, 2024
1 parent d2fb597 commit 51c9c52
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions packages/console/src/hooks/use-logto-skus.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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';
Expand All @@ -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 },
})
);
Expand Down

0 comments on commit 51c9c52

Please sign in to comment.