0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix: hide error toast for subscription hooks for prod env

This commit is contained in:
Darcy Ye 2024-08-08 18:18:05 +08:00
parent cec08acb52
commit 4fc1b9a492
No known key found for this signature in database
GPG key ID: B46F4C07EDEFC610
4 changed files with 9 additions and 5 deletions

View file

@ -5,7 +5,8 @@ import { type NewSubscriptionQuota } from '@/cloud/types/router';
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
const useNewSubscriptionQuota = (tenantId: string) => {
const cloudApi = useCloudApi();
// TODO: Console sometimes toast 401 unauthorized error, but can not be reproduced in local environment easily, we temporarily hide the error toast for prod env.
const cloudApi = useCloudApi({ hideErrorToast: !isDevFeaturesEnabled });
return useSWR<NewSubscriptionQuota, Error>(
isCloud && isDevFeaturesEnabled && tenantId && `/api/tenants/${tenantId}/subscription/quota`,

View file

@ -5,7 +5,8 @@ import { type NewSubscriptionScopeUsage } from '@/cloud/types/router';
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
const useNewSubscriptionScopeUsage = (tenantId: string) => {
const cloudApi = useCloudApi();
// TODO: Console sometimes toast 401 unauthorized error, but can not be reproduced in local environment easily, we temporarily hide the error toast for prod env.
const cloudApi = useCloudApi({ hideErrorToast: !isDevFeaturesEnabled });
const resourceEntityName = 'resources';
const roleEntityName = 'roles';

View file

@ -5,7 +5,8 @@ import { type NewSubscriptionUsage } from '@/cloud/types/router';
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
const useNewSubscriptionUsage = (tenantId: string) => {
const cloudApi = useCloudApi();
// TODO: Console sometimes toast 401 unauthorized error, but can not be reproduced in local environment easily, we temporarily hide the error toast for prod env.
const cloudApi = useCloudApi({ hideErrorToast: !isDevFeaturesEnabled });
return useSWR<NewSubscriptionUsage, Error>(
isCloud && isDevFeaturesEnabled && tenantId && `/api/tenants/${tenantId}/subscription/usage`,

View file

@ -2,10 +2,11 @@ import useSWR from 'swr';
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
import { type Subscription } from '@/cloud/types/router';
import { isCloud } from '@/consts/env';
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
const useSubscription = (tenantId: string) => {
const cloudApi = useCloudApi();
// TODO: Console sometimes toast 401 unauthorized error, but can not be reproduced in local environment easily, we temporarily hide the error toast for prod env.
const cloudApi = useCloudApi({ hideErrorToast: !isDevFeaturesEnabled });
return useSWR<Subscription, Error>(
// `tenantId` could be an empty string which may cause the request to fail
isCloud && tenantId && `/api/tenants/${tenantId}/subscription`,