mirror of
https://github.com/logto-io/logto.git
synced 2025-02-03 21:48:55 -05:00
refactor(console): navigate to plan & billing page on paywall button clicked (#5137)
This commit is contained in:
parent
1729def3dd
commit
70bd7322de
2 changed files with 2 additions and 30 deletions
|
@ -1,5 +1,4 @@
|
||||||
import { ReservedPlanId } from '@logto/schemas';
|
import { ReservedPlanId } from '@logto/schemas';
|
||||||
import { cond } from '@silverhand/essentials';
|
|
||||||
import { useContext } from 'react';
|
import { useContext } from 'react';
|
||||||
import { Trans, useTranslation } from 'react-i18next';
|
import { Trans, useTranslation } from 'react-i18next';
|
||||||
|
|
||||||
|
@ -10,7 +9,6 @@ import { isDevFeaturesEnabled } from '@/consts/env';
|
||||||
import { TenantsContext } from '@/contexts/TenantsProvider';
|
import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||||
import Button from '@/ds-components/Button';
|
import Button from '@/ds-components/Button';
|
||||||
import useApiResourcesUsage from '@/hooks/use-api-resources-usage';
|
import useApiResourcesUsage from '@/hooks/use-api-resources-usage';
|
||||||
import useSubscribe from '@/hooks/use-subscribe';
|
|
||||||
import useSubscriptionPlan from '@/hooks/use-subscription-plan';
|
import useSubscriptionPlan from '@/hooks/use-subscription-plan';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -23,7 +21,6 @@ function Footer({ isCreationLoading, onClickCreate }: Props) {
|
||||||
const { currentTenantId } = useContext(TenantsContext);
|
const { currentTenantId } = useContext(TenantsContext);
|
||||||
const { data: currentPlan } = useSubscriptionPlan(currentTenantId);
|
const { data: currentPlan } = useSubscriptionPlan(currentTenantId);
|
||||||
const { hasReachedLimit } = useApiResourcesUsage();
|
const { hasReachedLimit } = useApiResourcesUsage();
|
||||||
const { subscribe, isSubscribeLoading } = useSubscribe();
|
|
||||||
|
|
||||||
if (
|
if (
|
||||||
currentPlan &&
|
currentPlan &&
|
||||||
|
@ -35,20 +32,7 @@ function Footer({ isCreationLoading, onClickCreate }: Props) {
|
||||||
(!isDevFeaturesEnabled || currentPlan.id === ReservedPlanId.Free)
|
(!isDevFeaturesEnabled || currentPlan.id === ReservedPlanId.Free)
|
||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
<QuotaGuardFooter
|
<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',
|
|
||||||
});
|
|
||||||
})
|
|
||||||
)}
|
|
||||||
>
|
|
||||||
<Trans
|
<Trans
|
||||||
components={{
|
components={{
|
||||||
a: <ContactUsPhraseLink />,
|
a: <ContactUsPhraseLink />,
|
||||||
|
|
|
@ -9,7 +9,6 @@ import { isDevFeaturesEnabled } from '@/consts/env';
|
||||||
import { TenantsContext } from '@/contexts/TenantsProvider';
|
import { TenantsContext } from '@/contexts/TenantsProvider';
|
||||||
import Button from '@/ds-components/Button';
|
import Button from '@/ds-components/Button';
|
||||||
import useApplicationsUsage from '@/hooks/use-applications-usage';
|
import useApplicationsUsage from '@/hooks/use-applications-usage';
|
||||||
import useSubscribe from '@/hooks/use-subscribe';
|
|
||||||
import useSubscriptionPlan from '@/hooks/use-subscription-plan';
|
import useSubscriptionPlan from '@/hooks/use-subscription-plan';
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
|
@ -22,7 +21,6 @@ function Footer({ selectedType, isLoading, onClickCreate }: Props) {
|
||||||
const { currentTenantId } = useContext(TenantsContext);
|
const { currentTenantId } = useContext(TenantsContext);
|
||||||
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.paywall' });
|
const { t } = useTranslation(undefined, { keyPrefix: 'admin_console.upsell.paywall' });
|
||||||
const { data: currentPlan } = useSubscriptionPlan(currentTenantId);
|
const { data: currentPlan } = useSubscriptionPlan(currentTenantId);
|
||||||
const { subscribe, isSubscribeLoading } = useSubscribe();
|
|
||||||
const { hasAppsReachedLimit, hasMachineToMachineAppsReachedLimit } = useApplicationsUsage();
|
const { hasAppsReachedLimit, hasMachineToMachineAppsReachedLimit } = useApplicationsUsage();
|
||||||
|
|
||||||
if (currentPlan && selectedType) {
|
if (currentPlan && selectedType) {
|
||||||
|
@ -32,17 +30,7 @@ function Footer({ selectedType, isLoading, onClickCreate }: Props) {
|
||||||
// Todo @xiaoyijun [Pricing] Remove feature flag
|
// Todo @xiaoyijun [Pricing] Remove feature flag
|
||||||
if (isDevFeaturesEnabled && planId === ReservedPlanId.Free) {
|
if (isDevFeaturesEnabled && planId === ReservedPlanId.Free) {
|
||||||
return (
|
return (
|
||||||
<QuotaGuardFooter
|
<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',
|
|
||||||
});
|
|
||||||
}}
|
|
||||||
>
|
|
||||||
<Trans
|
<Trans
|
||||||
components={{
|
components={{
|
||||||
a: <ContactUsPhraseLink />,
|
a: <ContactUsPhraseLink />,
|
||||||
|
|
Loading…
Add table
Reference in a new issue