From c222cf7b96e02c347a1583bc5def3fb39d840355 Mon Sep 17 00:00:00 2001 From: CatsJuice Date: Tue, 16 Apr 2024 13:07:22 +0000 Subject: [PATCH] fix(core): wrong pricing state in billing ai card (#6583) --- .../setting-modal/general-setting/billing/index.tsx | 13 ++++++++++--- .../plans/ai/use-affine-ai-subscription.ts | 4 +++- packages/frontend/i18n/src/resources/en.json | 2 ++ 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/billing/index.tsx b/packages/frontend/core/src/components/affine/setting-modal/general-setting/billing/index.tsx index dd0e5d4c98..d75130eea1 100644 --- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/billing/index.tsx +++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/billing/index.tsx @@ -97,6 +97,7 @@ const SubscriptionSettings = () => { const [subscription, mutateSubscription] = useUserSubscription(); const [openCancelModal, setOpenCancelModal] = useState(false); const { + isFree: isFreeAI, actionType: aiActionType, Action: AIAction, billingTip, @@ -187,7 +188,11 @@ const SubscriptionSettings = () => { {aiPrice?.yearlyAmount ? ( { recurring={SubscriptionRecurring.Yearly} onSubscriptionUpdate={mutateSubscription} > - {aiActionType === 'subscribe' ? 'Purchase' : null} + {aiActionType === 'subscribe' + ? t['com.affine.payment.billing-setting.ai.purchase']() + : null} ) : null}

- {aiPriceReadable} + {isFreeAI ? '$0' : aiPriceReadable} /{aiPriceFrequency}

diff --git a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/ai/use-affine-ai-subscription.ts b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/ai/use-affine-ai-subscription.ts index 6895db8437..d2764f8895 100644 --- a/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/ai/use-affine-ai-subscription.ts +++ b/packages/frontend/core/src/components/affine/setting-modal/general-setting/plans/ai/use-affine-ai-subscription.ts @@ -32,6 +32,8 @@ export const useAffineAISubscription = () => { cancel: AICancel, }[actionType]; + const isFree = !subscription; + const billingTip = subscription?.nextBillAt ? t['com.affine.payment.ai.billing-tip.next-bill-at']({ due: timestampToLocalDate(subscription.nextBillAt), @@ -42,5 +44,5 @@ export const useAffineAISubscription = () => { }) : null; - return { actionType, Action, billingTip }; + return { actionType, Action, billingTip, isFree }; }; diff --git a/packages/frontend/i18n/src/resources/en.json b/packages/frontend/i18n/src/resources/en.json index 4bd4a2f96b..0e6e658db7 100644 --- a/packages/frontend/i18n/src/resources/en.json +++ b/packages/frontend/i18n/src/resources/en.json @@ -909,6 +909,8 @@ "com.affine.payment.billing-setting.upgrade": "Upgrade", "com.affine.payment.billing-setting.view-invoice": "View Invoice", "com.affine.payment.billing-setting.year": "year", + "com.affine.payment.billing-setting.ai.free-desc": "Yue are current on the Free plan.", + "com.affine.payment.billing-setting.ai.purchase": "Purchase", "com.affine.payment.blob-limit.description.local": "The maximum file upload size for local workspaces is {{quota}}.", "com.affine.payment.blob-limit.description.member": "The maximum file upload size for this joined workspace is {{quota}}. You can contact the owner of this workspace.", "com.affine.payment.blob-limit.description.owner.free": "{{planName}} users can upload files with a maximum size of {{currentQuota}}. You can upgrade your account to unlock a maximum file size of {{upgradeQuota}}.",