Skip to content

fix(wallet): honor configured quota units for reward transfers - #5808

Merged
Calcium-Ion merged 4 commits into
QuantumNous:mainfrom
A-Words:fix/issue-5414-quota-unit
Jul 7, 2026
Merged

fix(wallet): honor configured quota units for reward transfers#5808
Calcium-Ion merged 4 commits into
QuantumNous:mainfrom
A-Words:fix/issue-5414-quota-unit

Conversation

@A-Words

@A-Words A-Words commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

⚠️ 提交说明 / PR Notice

Important

  • 请提供人工撰写的简洁摘要,避免直接粘贴未经整理的 AI 输出。

📝 变更描述 / Description

修复 default 主题邀请奖励转余额弹窗的单位不一致问题。

转账输入现在使用站点当前配置的额度展示单位,并在提交前转换为后端所需的原始 quota。最低金额、步进和可转上限也会根据 quota_per_unit 及当前货币汇率动态计算,不再依赖前端硬编码的 500000

同时在后台的新用户额度、邀请者奖励和受邀者奖励字段下增加格式化金额预览,方便管理员确认原始 quota 对应的实际展示金额。

🚀 变更类型 / Type of change

  • 🐛 Bug 修复 (Bug fix) - 请关联对应 Issue,避免将设计取舍、理解偏差或预期不一致直接归类为 bug
  • ✨ 新功能 (New feature) - 重大特性建议先通过 Issue 沟通
  • ⚡ 性能优化 / 重构 (Refactor)
  • 📝 文档更新 (Documentation)

🔗 关联任务 / Related Issue

✅ 提交前检查项 / Checklist

  • 人工确认: 我已亲自整理并撰写此描述,没有直接粘贴未经处理的 AI 输出。
  • 非重复提交: 我已搜索现有的 IssuesPRs,确认不是重复提交。
  • Bug fix 说明: 若此 PR 标记为 Bug fix,我已提交或关联对应 Issue,且不会将设计取舍、预期不一致或理解偏差直接归类为 bug。
  • 变更理解: 我已理解这些更改的工作原理及可能影响。
  • 范围聚焦: 本 PR 未包含任何与当前任务无关的代码改动。
  • 本地验证: 已在本地运行并通过测试或手动验证,维护者可以据此复核结果。
  • 安全合规: 代码中无敏感凭据,且符合项目代码规范。

📸 运行证明 / Proof of Work

转账输入站点配置的单位数值即可,不再始终需要输入原始 quota。

image image

Summary by CodeRabbit

  • New Features
    • Quota settings guidance now displays properly formatted quota values for new users and invite-related quotas.
    • Transfer dialog now computes transferable limits from the system currency settings and entered amount.
  • Bug Fixes
    • Transfer is blocked and the Transfer button is disabled when the computed quota is invalid or outside the allowed range.
    • Transfer dialog resets the amount to a valid starting value when opened.
  • Localization
    • Updated quota-related UI strings across supported languages to use a formattedQuota placeholder.

@coderabbitai

coderabbitai Bot commented Jun 29, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e5029a23-dd8b-41da-8c38-efb35d6e16dd

📥 Commits

Reviewing files that changed from the base of the PR and between a33469b and de07a02.

📒 Files selected for processing (1)
  • web/default/src/features/system-settings/general/quota-settings-section.tsx
🚧 Files skipped from review as they are similar to previous changes (1)
  • web/default/src/features/system-settings/general/quota-settings-section.tsx

Walkthrough

The transfer dialog now derives quota conversion and transfer limits from system currency config instead of a hardcoded constant. Admin quota settings and locale strings now display formatted quota values in the related descriptions.

Changes

Currency-aware quota display and transfer

Layer / File(s) Summary
Transfer dialog uses system currency config
web/default/src/features/wallet/constants.ts, web/default/src/features/wallet/components/dialogs/transfer-dialog.tsx
Removes QUOTA_PER_DOLLAR and updates the transfer dialog to compute minimum/maximum amounts, transfer quota, validation, button state, and input constraints from system currency config and formatting helpers.
Quota settings show formatted values
web/default/src/features/system-settings/general/quota-settings-section.tsx
Imports formatQuota, defines a quota input formatter, updates the number change type, and renders formatted quota values in the New User Quota, Inviter Reward, and Invitee Reward descriptions.
Locale strings add formatted quota placeholders
web/default/src/i18n/locales/*.json
Adds or updates quota translation entries across supported locales to include {{formattedQuota}} placeholders for the updated descriptions.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

  • QuantumNous/new-api#2916: Updates quota/currency conversion logic and transfer UI limits, closely matching the same amount-to-quota conversion path.
  • QuantumNous/new-api#2272: Related to quota unit switching in the classic theme, which overlaps with the quota display and conversion behavior here.

Suggested reviewers

  • Calcium-Ion
  • seefs001

Poem

🐇 I hopped by the quota with a curious grin,
The config said “use me,” so the change could begin.
No hardcoded carrot-stick, no awkward old fight,
Just formatted quotas and translations done right.
Hoppy times for units — now everything aligns!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title is concise and directly describes the main wallet quota-unit fix.
Linked Issues check ✅ Passed The changes address the transfer dialog unit mismatch, remove the hardcoded quota rate, and add formatted previews for admin quota fields.
Out of Scope Changes check ✅ Passed No clearly unrelated changes are present; the locale updates and admin previews support the stated quota-unit behavior.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@web/default/src/features/system-settings/general/quota-settings-section.tsx`:
- Around line 143-144: The quota description text in
`quota-settings-section.tsx` is mixing an unnormalized preview value with
untranslated string concatenation. Update the relevant description renderers to
use a normalized quota value from `field.value` (treat empty string as 0 before
calling `formatQuota`) and pass the entire sentence through `t()` with a
`formattedQuota` placeholder instead of appending the formatted value outside
the translation. Apply the same fix in the description blocks used by the quota
fields around `handleNumberChange`, `formatQuota`, and the related localized
text sections.

In `@web/default/src/features/wallet/components/dialogs/transfer-dialog.tsx`:
- Around line 52-63: The transfer dialog is only sanitizing quotaPerUnit for
minimumQuota, but the conversion path still uses the raw store value, which can
make minimumAmount invalid and transferQuota collapse to zero. Update
transfer-dialog.tsx around the useSystemConfigStore, quotaUnitsToDollars, and
parseQuotaFromDollars flow so the same normalized quotaPerUnit is used
consistently for both display and parsing, or move the fallback into the shared
currency formatter/parser helpers. Keep the fallback behavior aligned with
DEFAULT_CURRENCY_CONFIG.quotaPerUnit so the dialog remains usable when the
stored value is non-positive.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5b4fc871-0fa4-468b-ad49-7585f7807075

📥 Commits

Reviewing files that changed from the base of the PR and between 43591fb and 71a15cd.

📒 Files selected for processing (3)
  • web/default/src/features/system-settings/general/quota-settings-section.tsx
  • web/default/src/features/wallet/components/dialogs/transfer-dialog.tsx
  • web/default/src/features/wallet/constants.ts
💤 Files with no reviewable changes (1)
  • web/default/src/features/wallet/constants.ts

Comment thread web/default/src/features/system-settings/general/quota-settings-section.tsx Outdated

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
web/default/src/features/system-settings/general/quota-settings-section.tsx (1)

85-90: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Normalize valueAsNumber before onChange.
valueAsNumber can be NaN for intermediate invalid number input, and value={field.value ?? ''} will pass that through to the controlled field. Coerce NaN to '' here to avoid React’s NaN value warning and keep editing stable.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@web/default/src/features/system-settings/general/quota-settings-section.tsx`
around lines 85 - 90, Normalize the value passed from handleNumberChange before
calling onChange, since event.currentTarget.valueAsNumber can produce NaN for
temporary invalid input and then flow into the controlled field via
value={field.value ?? ''}. Update the handleNumberChange logic in
quota-settings-section.tsx so it coerces NaN to an empty string instead of
forwarding it, keeping the input stable and avoiding React warnings.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Outside diff comments:
In `@web/default/src/features/system-settings/general/quota-settings-section.tsx`:
- Around line 85-90: Normalize the value passed from handleNumberChange before
calling onChange, since event.currentTarget.valueAsNumber can produce NaN for
temporary invalid input and then flow into the controlled field via
value={field.value ?? ''}. Update the handleNumberChange logic in
quota-settings-section.tsx so it coerces NaN to an empty string instead of
forwarding it, keeping the input stable and avoiding React warnings.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: ef6805cb-4129-4424-b70a-67d5dff1b0d1

📥 Commits

Reviewing files that changed from the base of the PR and between 71a15cd and a33469b.

📒 Files selected for processing (7)
  • web/default/src/features/system-settings/general/quota-settings-section.tsx
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/fr.json
  • web/default/src/i18n/locales/ja.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json
  • web/default/src/i18n/locales/zh.json
✅ Files skipped from review due to trivial changes (3)
  • web/default/src/i18n/locales/en.json
  • web/default/src/i18n/locales/ru.json
  • web/default/src/i18n/locales/vi.json

@Calcium-Ion
Calcium-Ion merged commit 90fa6fe into QuantumNous:main Jul 7, 2026
1 check passed
wuwenrui pushed a commit to wuwenrui/new-api that referenced this pull request Jul 7, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input
xiaomingchen pushed a commit to xiaomingchen/new-api that referenced this pull request Jul 10, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input
Jacobinwwey pushed a commit to Jacobinwwey/new-api that referenced this pull request Jul 11, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input
ruanhangjian pushed a commit to ruanhangjian/new-api that referenced this pull request Jul 11, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input
lizhongyi1209 pushed a commit to lizhongyi1209/new-api that referenced this pull request Jul 13, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input

(cherry picked from commit 90fa6fe)
noah-wung pushed a commit to noah-wung/new-api that referenced this pull request Jul 17, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input
zhaodechao2008 pushed a commit to zhaodechao2008/new-api that referenced this pull request Jul 27, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input
330079598 pushed a commit to 330079598/new-api that referenced this pull request Aug 19, 2026
…umNous#5808)

* fix(wallet): honor configured quota units for reward transfers

* fix(i18n): localize quota preview descriptions

* fix(settings): normalize invalid quota input
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

default 主题:邀请奖励「转余额」弹窗输入单位与货币显示不一致,且 QUOTA_PER_DOLLAR 硬编码 500000

2 participants