0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2025-01-27 21:39:16 -05:00

refactor(console): navigate to plan & billing page on paywall button clicked (#5137)

This commit is contained in:
Xiao Yijun 2023-12-21 15:01:37 +08:00 committed by GitHub
parent 1729def3dd
commit 70bd7322de
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 2 additions and 30 deletions

View file

@ -1,5 +1,4 @@
import { ReservedPlanId } from '@logto/schemas';
import { cond } from '@silverhand/essentials';
import { useContext } from 'react';
import { Trans, useTranslation } from 'react-i18next';
@ -10,7 +9,6 @@ import { isDevFeaturesEnabled } from '@/consts/env';
import { TenantsContext } from '@/contexts/TenantsProvider';
import Button from '@/ds-components/Button';
import useApiResourcesUsage from '@/hooks/use-api-resources-usage';
import useSubscribe from '@/hooks/use-subscribe';
import useSubscriptionPlan from '@/hooks/use-subscription-plan';
type Props = {
@ -23,7 +21,6 @@ function Footer({ isCreationLoading, onClickCreate }: Props) {
const { currentTenantId } = useContext(TenantsContext);
const { data: currentPlan } = useSubscriptionPlan(currentTenantId);
const { hasReachedLimit } = useApiResourcesUsage();
const { subscribe, isSubscribeLoading } = useSubscribe();
if (
currentPlan &&
@ -35,20 +32,7 @@ function Footer({ isCreationLoading, onClickCreate }: Props) {
(!isDevFeaturesEnabled || currentPlan.id === ReservedPlanId.Free)
) {
return (
<QuotaGuardFooter
isLoading={isSubscribeLoading}
onClickUpgrade={cond(
isDevFeaturesEnabled &&
(() => {
void subscribe({
// Todo @xiaoyijun [Pricing] Replace 'Hobby' with 'Pro' when pricing is ready, in MVP, we use 'Hobby' as the new pro plan id
planId: ReservedPlanId.Hobby,
tenantId: currentTenantId,
callbackPage: '/api-resources/create',
});
})
)}
>
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,

View file

@ -9,7 +9,6 @@ import { isDevFeaturesEnabled } from '@/consts/env';
import { TenantsContext } from '@/contexts/TenantsProvider';
import Button from '@/ds-components/Button';
import useApplicationsUsage from '@/hooks/use-applications-usage';
import useSubscribe from '@/hooks/use-subscribe';
import useSubscriptionPlan from '@/hooks/use-subscription-plan';
type Props = {
@ -22,7 +21,6 @@ function Footer({ selectedType, isLoading, onClickCreate }: Props) {
const { currentTenantId } = useContext(TenantsContext);
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.paywall' });
const { data: currentPlan } = useSubscriptionPlan(currentTenantId);
const { subscribe, isSubscribeLoading } = useSubscribe();
const { hasAppsReachedLimit, hasMachineToMachineAppsReachedLimit } = useApplicationsUsage();
if (currentPlan && selectedType) {
@ -32,17 +30,7 @@ function Footer({ selectedType, isLoading, onClickCreate }: Props) {
// Todo @xiaoyijun [Pricing] Remove feature flag
if (isDevFeaturesEnabled && planId === ReservedPlanId.Free) {
return (
<QuotaGuardFooter
isLoading={isSubscribeLoading}
onClickUpgrade={() => {
void subscribe({
// Todo @xiaoyijun [Pricing] Replace 'Hobby' with 'Pro' when pricing is ready, in MVP, we use 'Hobby' as the new pro plan id
planId: ReservedPlanId.Hobby,
tenantId: currentTenantId,
callbackPage: '/applications/create',
});
}}
>
<QuotaGuardFooter>
<Trans
components={{
a: <ContactUsPhraseLink />,