fix(core): wrong pricing state in billing ai card (#6583)

This commit is contained in:
CatsJuice 2024-04-16 13:07:22 +00:00
parent f6fcbd8ea9
commit c222cf7b96
No known key found for this signature in database
GPG Key ID: 1C1E76924FAFDDE4
3 changed files with 15 additions and 4 deletions

View File

@ -97,6 +97,7 @@ const SubscriptionSettings = () => {
const [subscription, mutateSubscription] = useUserSubscription(); const [subscription, mutateSubscription] = useUserSubscription();
const [openCancelModal, setOpenCancelModal] = useState(false); const [openCancelModal, setOpenCancelModal] = useState(false);
const { const {
isFree: isFreeAI,
actionType: aiActionType, actionType: aiActionType,
Action: AIAction, Action: AIAction,
billingTip, billingTip,
@ -187,7 +188,11 @@ const SubscriptionSettings = () => {
<SettingRow <SettingRow
spreadCol={false} spreadCol={false}
name={t['com.affine.payment.billing-setting.ai-plan']()} name={t['com.affine.payment.billing-setting.ai-plan']()}
desc={billingTip} desc={
isFreeAI
? t['com.affine.payment.billing-setting.ai.free-desc']()
: billingTip
}
/> />
{aiPrice?.yearlyAmount ? ( {aiPrice?.yearlyAmount ? (
<AIAction <AIAction
@ -196,12 +201,14 @@ const SubscriptionSettings = () => {
recurring={SubscriptionRecurring.Yearly} recurring={SubscriptionRecurring.Yearly}
onSubscriptionUpdate={mutateSubscription} onSubscriptionUpdate={mutateSubscription}
> >
{aiActionType === 'subscribe' ? 'Purchase' : null} {aiActionType === 'subscribe'
? t['com.affine.payment.billing-setting.ai.purchase']()
: null}
</AIAction> </AIAction>
) : null} ) : null}
</div> </div>
<p className={styles.planPrice}> <p className={styles.planPrice}>
{aiPriceReadable} {isFreeAI ? '$0' : aiPriceReadable}
<span className={styles.billingFrequency}>/{aiPriceFrequency}</span> <span className={styles.billingFrequency}>/{aiPriceFrequency}</span>
</p> </p>
</div> </div>

View File

@ -32,6 +32,8 @@ export const useAffineAISubscription = () => {
cancel: AICancel, cancel: AICancel,
}[actionType]; }[actionType];
const isFree = !subscription;
const billingTip = subscription?.nextBillAt const billingTip = subscription?.nextBillAt
? t['com.affine.payment.ai.billing-tip.next-bill-at']({ ? t['com.affine.payment.ai.billing-tip.next-bill-at']({
due: timestampToLocalDate(subscription.nextBillAt), due: timestampToLocalDate(subscription.nextBillAt),
@ -42,5 +44,5 @@ export const useAffineAISubscription = () => {
}) })
: null; : null;
return { actionType, Action, billingTip }; return { actionType, Action, billingTip, isFree };
}; };

View File

@ -909,6 +909,8 @@
"com.affine.payment.billing-setting.upgrade": "Upgrade", "com.affine.payment.billing-setting.upgrade": "Upgrade",
"com.affine.payment.billing-setting.view-invoice": "View Invoice", "com.affine.payment.billing-setting.view-invoice": "View Invoice",
"com.affine.payment.billing-setting.year": "year", "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.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.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}}.", "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}}.",