From 8f34523a74b409e73d9c884fb95a2d87d1ce0069 Mon Sep 17 00:00:00 2001 From: Darcy Ye Date: Mon, 19 Aug 2024 18:41:58 +0800 Subject: [PATCH] chore(console): fix add-on issues --- .../ApplicationCreation/CreateForm/index.tsx | 8 ++++++-- packages/console/src/components/BillInfo/index.tsx | 4 ++-- .../src/components/ChargeNotification/index.tsx | 4 ++-- packages/console/src/components/PlanUsage/index.tsx | 10 +++++----- packages/console/src/consts/external-links.ts | 1 - .../pages/ApiResources/components/CreateForm/index.tsx | 4 +++- .../TenantSettings/Subscription/CurrentPlan/index.tsx | 2 +- .../TenantMembers/InviteMemberModal/index.tsx | 2 +- 8 files changed, 20 insertions(+), 15 deletions(-) diff --git a/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx b/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx index f71a5ed378a2..0a0370e643d8 100644 --- a/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx +++ b/packages/console/src/components/ApplicationCreation/CreateForm/index.tsx @@ -25,6 +25,7 @@ import { trySubmitSafe } from '@/utils/form'; import Footer from './Footer'; import styles from './index.module.scss'; +import useApplicationsUsage from '@/hooks/use-applications-usage'; type FormData = { type: ApplicationType; @@ -56,7 +57,7 @@ function CreateForm({ defaultValues: { type: defaultCreateType, isThirdParty: isDefaultCreateThirdParty }, }); const { - currentSubscription: { isAddOnAvailable }, + currentSubscription: { isAddOnAvailable, planId }, } = useContext(SubscriptionDataContext); const { user } = useCurrentUser(); const { mutate: mutateGlobal } = useSWRConfig(); @@ -72,6 +73,8 @@ function CreateForm({ const { t } = useTranslation(undefined, { keyPrefix: 'admin_console' }); const api = useApi(); + const { hasMachineToMachineAppsReachedLimit } = useApplicationsUsage(); + const onSubmit = handleSubmit( trySubmitSafe(async (data) => { if (isSubmitting) { @@ -124,9 +127,10 @@ function CreateForm({ paywall={conditional( isAddOnAvailable && watch('type') === ApplicationType.MachineToMachine && + planId !== ReservedPlanId.Pro && ReservedPlanId.Pro )} - hasAddOnTag={isAddOnAvailable && watch('type') === ApplicationType.MachineToMachine} + hasAddOnTag={isAddOnAvailable && watch('type') === ApplicationType.MachineToMachine && hasMachineToMachineAppsReachedLimit} size={defaultCreateType ? 'medium' : 'large'} footer={