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:
parent
cec08acb52
commit
4fc1b9a492
4 changed files with 9 additions and 5 deletions
|
@ -5,7 +5,8 @@ import { type NewSubscriptionQuota } from '@/cloud/types/router';
|
||||||
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
|
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
|
||||||
|
|
||||||
const useNewSubscriptionQuota = (tenantId: string) => {
|
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>(
|
return useSWR<NewSubscriptionQuota, Error>(
|
||||||
isCloud && isDevFeaturesEnabled && tenantId && `/api/tenants/${tenantId}/subscription/quota`,
|
isCloud && isDevFeaturesEnabled && tenantId && `/api/tenants/${tenantId}/subscription/quota`,
|
||||||
|
|
|
@ -5,7 +5,8 @@ import { type NewSubscriptionScopeUsage } from '@/cloud/types/router';
|
||||||
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
|
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
|
||||||
|
|
||||||
const useNewSubscriptionScopeUsage = (tenantId: string) => {
|
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 resourceEntityName = 'resources';
|
||||||
const roleEntityName = 'roles';
|
const roleEntityName = 'roles';
|
||||||
|
|
|
@ -5,7 +5,8 @@ import { type NewSubscriptionUsage } from '@/cloud/types/router';
|
||||||
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
|
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
|
||||||
|
|
||||||
const useNewSubscriptionUsage = (tenantId: string) => {
|
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>(
|
return useSWR<NewSubscriptionUsage, Error>(
|
||||||
isCloud && isDevFeaturesEnabled && tenantId && `/api/tenants/${tenantId}/subscription/usage`,
|
isCloud && isDevFeaturesEnabled && tenantId && `/api/tenants/${tenantId}/subscription/usage`,
|
||||||
|
|
|
@ -2,10 +2,11 @@ import useSWR from 'swr';
|
||||||
|
|
||||||
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
|
import { useCloudApi } from '@/cloud/hooks/use-cloud-api';
|
||||||
import { type Subscription } from '@/cloud/types/router';
|
import { type Subscription } from '@/cloud/types/router';
|
||||||
import { isCloud } from '@/consts/env';
|
import { isCloud, isDevFeaturesEnabled } from '@/consts/env';
|
||||||
|
|
||||||
const useSubscription = (tenantId: string) => {
|
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>(
|
return useSWR<Subscription, Error>(
|
||||||
// `tenantId` could be an empty string which may cause the request to fail
|
// `tenantId` could be an empty string which may cause the request to fail
|
||||||
isCloud && tenantId && `/api/tenants/${tenantId}/subscription`,
|
isCloud && tenantId && `/api/tenants/${tenantId}/subscription`,
|
||||||
|
|
Loading…
Reference in a new issue