|
1 | 1 | import { Role } from '@teable/core'; |
2 | 2 | import { BillingProductLevel } from '@teable/openapi'; |
| 3 | +import { UsageLimitModalType, useUsageLimitModalStore } from '@teable/sdk/components/billing/store'; |
3 | 4 | import { useBase } from '@teable/sdk/hooks'; |
4 | 5 | import type { Base } from '@teable/sdk/model'; |
5 | 6 | import { toast } from '@teable/ui-lib/shadcn/ui/sonner'; |
6 | | -import { useRouter } from 'next/router'; |
7 | 7 | import { useTranslation } from 'next-i18next'; |
8 | 8 | import { useMemo, useCallback, type ReactElement, cloneElement } from 'react'; |
9 | 9 | import { useBillingLevel } from '../../hooks/useBillingLevel'; |
@@ -51,12 +51,12 @@ export const UpgradeWrapper: React.FC<IUpgradeWrapperProps> = ({ |
51 | 51 | targetBillingLevel, |
52 | 52 | onUpgradeClick, |
53 | 53 | }) => { |
54 | | - const router = useRouter(); |
55 | 54 | const isCloud = useIsCloud(); |
56 | 55 | const isCommunity = useIsCommunity(); |
57 | 56 | const isEE = useIsEE(); |
58 | 57 | const base = useBase() as Base | undefined; |
59 | 58 | const { t } = useTranslation('common'); |
| 59 | + const { openModal } = useUsageLimitModalStore(); |
60 | 60 | spaceId = base?.spaceId ?? spaceId; |
61 | 61 | const baseId = base?.id; |
62 | 62 | // EE starts from pro level |
@@ -95,15 +95,14 @@ export const UpgradeWrapper: React.FC<IUpgradeWrapperProps> = ({ |
95 | 95 | return; |
96 | 96 | } |
97 | 97 |
|
98 | | - router.push(`/space/${spaceId}/setting/plan`); |
| 98 | + openModal(UsageLimitModalType.Upgrade); |
99 | 99 | } else { |
100 | 100 | window.open('https://app.teable.ai/public/pricing?host=self-hosted', '_blank'); |
101 | 101 | } |
102 | | - }, [onUpgradeClick, isCloud, spaceId, isSpaceOwner, t, router]); |
| 102 | + }, [isCloud, spaceId, isSpaceOwner, t, openModal, onUpgradeClick]); |
103 | 103 |
|
104 | 104 | const billingConfig = useBillingLevelConfig(targetBillingLevel); |
105 | 105 |
|
106 | | - // 创建badge组件 |
107 | 106 | const badge = useMemo(() => { |
108 | 107 | if (!needsUpgrade) { |
109 | 108 | return null; |
|
0 commit comments