From de90e11cdffe9221d6c264255c50fc4e0f11e177 Mon Sep 17 00:00:00 2001 From: t0ng7u Date: Sun, 1 Feb 2026 15:40:26 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat:=20Extract=20quota=20conversio?= =?UTF-8?q?n=20helpers=20to=20shared=20utils?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move quota display/conversion helpers into web/src/helpers/quota.js and update the subscription plan editor to import and use the shared utilities instead of inline functions. --- .../subscriptions/SubscriptionsColumnDefs.jsx | 33 +++++++++++-------- .../modals/AddEditSubscriptionModal.jsx | 32 ++++++++---------- .../topup/SubscriptionPlansCard.jsx | 3 +- .../modals/SubscriptionPurchaseModal.jsx | 1 - web/src/helpers/quota.js | 25 ++++++++++++++ 5 files changed, 59 insertions(+), 35 deletions(-) create mode 100644 web/src/helpers/quota.js diff --git a/web/src/components/table/subscriptions/SubscriptionsColumnDefs.jsx b/web/src/components/table/subscriptions/SubscriptionsColumnDefs.jsx index 1cff521bc..6bf18ba51 100644 --- a/web/src/components/table/subscriptions/SubscriptionsColumnDefs.jsx +++ b/web/src/components/table/subscriptions/SubscriptionsColumnDefs.jsx @@ -27,8 +27,9 @@ import { Popover, Divider, Badge, + Tooltip, } from '@douyinfe/semi-ui'; -import { IconEdit, IconStop, IconPlay } from '@douyinfe/semi-icons'; +import { renderQuota } from '../../../helpers'; import { convertUSDToCurrency } from '../../../helpers/render'; const { Text } = Typography; @@ -81,7 +82,13 @@ const renderPlanTitle = (text, record, t) => { {convertUSDToCurrency(Number(plan?.price_amount || 0), 2)} {t('总额度')} - {plan?.total_amount > 0 ? plan.total_amount : t('不限')} + {plan?.total_amount > 0 ? ( + + {renderQuota(plan.total_amount)} + + ) : ( + {t('不限')} + )} {t('升级分组')} {plan?.upgrade_group ? plan.upgrade_group : t('不升级')} {t('购买上限')} @@ -165,7 +172,13 @@ const renderTotalAmount = (text, record, t) => { const total = Number(record?.plan?.total_amount || 0); return ( 0 ? 'secondary' : 'tertiary'}> - {total > 0 ? total : t('不限')} + {total > 0 ? ( + + {renderQuota(total)} + + ) : ( + t('不限') + )} ); }; @@ -236,30 +249,22 @@ const renderOperations = (text, record, { openEdit, setPlanEnabled, t }) => { return ( {isEnabled ? ( - ) : (