Skip to content

feat: update price display use current currency symbol - #2360

Merged
seefs001 merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr2/fix-price-currency
Dec 9, 2025
Merged

feat: update price display use current currency symbol#2360
seefs001 merged 1 commit into
QuantumNous:mainfrom
feitianbubu:pr2/fix-price-currency

Conversation

@feitianbubu

@feitianbubu feitianbubu commented Dec 3, 2025

Copy link
Copy Markdown
Member

使用日志详情的货币单位使用设置的单位
比如当前设置为人民币
之前:
image

修复后:
image

Summary by CodeRabbit

  • Bug Fixes
    • Price displays now correctly apply current exchange rates and show appropriate currency symbols based on your configuration.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai

coderabbitai Bot commented Dec 3, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The renderPriceSimpleCore function in the render helper is enhanced to fetch currency configuration, apply exchange rate conversion to the model price, and include the currency symbol in the formatted price output. The display price is now calculated by multiplying the model price by the exchange rate.

Changes

Cohort / File(s) Summary
Price rendering with currency conversion
web/src/helpers/render.jsx
Updated renderPriceSimpleCore to fetch currency config (symbol and rate), apply exchange rate to modelPrice, and format output with currency symbol using computed displayPrice (modelPrice × rate)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • Key focus areas: Currency rate application logic and correctness of exchange rate calculation (modelPrice × rate)
  • Attention needed: Verify that currency config fetching doesn't introduce performance issues in rendering; confirm i18n template updates are backward-compatible
  • Edge cases to check: Handling of undefined/null currency config; behavior when exchange rate is missing or zero

Possibly related PRs

  • PR #2111: Changes how monetary values are rendered in RechargeCard.jsx to use converted display values and configured currency symbols, mirroring the same currency conversion pattern applied in this PR

Suggested reviewers

  • seefs001

Poem

🐰 A currency converter hops into view,
Exchange rates dance as prices renew,
Symbols now sparkle where numbers once flew,
Global transactions feel fresh and so true! ✨💱

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: updating price display to use the current currency symbol, which aligns with the PR objective of making currency units reflect configured settings.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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 and usage tips.

@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: 0

🧹 Nitpick comments (1)
web/src/helpers/render.jsx (1)

1089-1094: Currency conversion/symbol integration looks correct; you can avoid an extra config lookup

Using getCurrencyConfig() here and applying modelPrice * rate is consistent with the other pricing helpers and achieves the PR goal of honoring the configured currency. Since the currency data is only needed when modelPrice !== -1, you can optionally move the call into that branch to skip a localStorage read + JSON parse on the pure-ratio path.

-  const { symbol, rate } = getCurrencyConfig();
-  if (modelPrice !== -1) {
-    const displayPrice = (modelPrice * rate).toFixed(6);
-    return i18next.t('价格:{{symbol}}{{price}} * {{ratioType}}:{{ratio}}', {
-      symbol: symbol,
-      price: displayPrice,
+  if (modelPrice !== -1) {
+    const { symbol, rate } = getCurrencyConfig();
+    const displayPrice = (modelPrice * rate).toFixed(6);
+    return i18next.t('价格:{{symbol}}{{price}} * {{ratioType}}:{{ratio}}', {
+      symbol,
+      price: displayPrice,
       ratioType: ratioLabel,
       ratio: finalGroupRatio,
     });
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 7d1bad1 and 293a5de.

📒 Files selected for processing (1)
  • web/src/helpers/render.jsx (1 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
web/src/helpers/render.jsx (2)
web/src/hooks/model-pricing/useModelPricingData.jsx (1)
  • displayPrice (174-186)
web/src/helpers/utils.jsx (1)
  • symbol (649-649)

@seefs001
seefs001 merged commit 23292a5 into QuantumNous:main Dec 9, 2025
1 check passed
ennnnny pushed a commit to ennnnny/new-api that referenced this pull request Mar 17, 2026
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.

2 participants