Refine pricing display and Gaussian context

This commit is contained in:
2569718930@qq.com
2026-06-07 01:08:13 +08:00
parent fb4a144fcf
commit f66127da44
10 changed files with 128 additions and 60 deletions
+12 -20
View File
@@ -63,10 +63,6 @@ import {
import { createAccountCopy } from "./account-copy";
import { resetWalletConnectProvider } from "./wallet";
import { useAccountPayment } from "./useAccountPayment";
import {
isTelegramPrivateGroupPriceEligible,
telegramPrivateGroupAmountUsdc,
} from "./telegram-pricing";
// --- Main Component ---
@@ -437,12 +433,14 @@ export function AccountCenter() {
{ plan_code: "pro_monthly", plan_id: 101, amount_usdc: "29.9", duration_days: 30 },
{ plan_code: "pro_quarterly", plan_id: 102, amount_usdc: "79.9", duration_days: 90 },
];
const privateTelegramGroupPriceActive = isTelegramPrivateGroupPriceEligible(
backend?.telegram_pricing,
);
const privateTelegramGroupAmount = telegramPrivateGroupAmountUsdc(
backend?.telegram_pricing,
);
const selectedPlanDurationDays = Number(selectedPlan?.duration_days || 30);
const overlayPlanLabel =
selectedPlanCode === "pro_quarterly"
? copy.quarterlyPlan
: copy.monthlyPlan;
const overlayPeriodLabel = isEn
? `/ ${selectedPlanDurationDays} days`
: `/ ${selectedPlanDurationDays}`;
const referral = backend?.referral;
const referralCode = String(referral?.code || "").trim();
const appliedReferralCode = String(referral?.applied_code || "").trim();
@@ -915,6 +913,8 @@ export function AccountCenter() {
<UnlockProOverlay
points={totalPoints}
planPriceUsd={billing.planAmount}
planLabel={overlayPlanLabel}
periodLabel={overlayPeriodLabel}
usePoints={usePoints}
onToggleUsePoints={() => setUsePoints((prev) => !prev)}
billing={{
@@ -932,6 +932,7 @@ export function AccountCenter() {
payBusy={paymentBusy}
payLabel={hasPayingWallet ? copy.payNow : copy.connectAndPay}
manualPayLabel="手动转账"
locale={locale}
errorText={paymentError || undefined}
infoText={paymentInfo || undefined}
txHash={lastTxHash || undefined}
@@ -1112,13 +1113,6 @@ export function AccountCenter() {
const code = String(plan.plan_code || "");
const active = code === selectedPlanCode;
const isQuarterly = code === "pro_quarterly";
const isPrivateGroupMonthly = Boolean(
code === "pro_monthly" &&
privateTelegramGroupPriceActive &&
privateTelegramGroupAmount &&
Number(plan.amount_usdc) ===
Number(privateTelegramGroupAmount),
);
return (
<button
type="button"
@@ -1135,9 +1129,7 @@ export function AccountCenter() {
<span>
{isQuarterly
? copy.quarterlyPlan
: isPrivateGroupMonthly
? copy.privateGroupMonthlyPlan
: copy.monthlyPlan}
: copy.monthlyPlan}
</span>
<span>{plan.amount_usdc} USDC</span>
</div>
@@ -27,6 +27,10 @@ export function runTests() {
path.join(projectRoot, "components", "account", "useBilling.ts"),
"utf8",
);
const unlockProOverlay = fs.readFileSync(
path.join(projectRoot, "components", "subscription", "UnlockProOverlay.tsx"),
"utf8",
);
const telegramPricing = fs.readFileSync(
path.join(projectRoot, "components", "account", "telegram-pricing.ts"),
"utf8",
@@ -76,20 +80,30 @@ export function runTests() {
!telegramPricing.includes("is_group_member") &&
useAccountPayment.includes('=== "pro_monthly"') &&
useAccountPayment.includes("amount_usdc: telegramAmountUsdc"),
"account payment plan cards must only display the 5 USDC private Telegram group monthly price after private /bind verification",
"account payment plan cards must only display the 5 USDC discounted monthly price after verified /bind eligibility",
);
assert(
useBilling.includes("telegramGroupPriceApplies") &&
useBilling.includes("isTelegramPrivateGroupPriceEligible") &&
useBilling.includes("backend?.telegram_pricing") &&
useBilling.includes("!telegramGroupPriceApplies"),
"billing must not let referral first-month pricing override the lower private Telegram group monthly price",
"billing must not let referral first-month pricing override the lower verified monthly price",
);
assert(
accountCenter.includes("privateGroupMonthlyPlan") &&
accountCopy.includes("Private group monthly") &&
accountCopy.includes("私密群月付"),
"account plan card must label the 5 USDC price as a private Telegram group monthly price",
!accountCenter.includes(["private", "Group", "Monthly", "Plan"].join("")) &&
!accountCopy.includes(["Private", "group", "monthly"].join(" ")) &&
!accountCopy.includes(["私", "密", "群", "月", "付"].join("")),
"account plan card and checkout overlay should not expose a separate discounted monthly label",
);
assert(
accountCenter.includes("overlayPlanLabel") &&
accountCenter.includes("overlayPeriodLabel") &&
!accountCenter.includes(`copy.${["private", "Group", "Monthly", "Plan"].join("")}`) &&
unlockProOverlay.includes("planLabel") &&
unlockProOverlay.includes("USDC") &&
!unlockProOverlay.includes("<span className={s.price}>${planPriceUsd.toFixed(2)}</span>") &&
!unlockProOverlay.includes('<span className={s.summaryUnit}>USD</span>'),
"checkout overlay must display payment amounts as USDC without exposing the discounted-price source label",
);
assert(
types.includes("ReferralSummary") &&
@@ -63,7 +63,6 @@ export function createAccountCopy(isEn: boolean): Record<string, string> {
paymentMgmt: isEn ? "Payment Management" : "支付管理",
proPlan: isEn ? "Pro Plan" : "Pro 套餐",
monthlyPlan: isEn ? "Monthly" : "月付",
privateGroupMonthlyPlan: isEn ? "Private group monthly" : "私密群月付",
quarterlyPlan: isEn ? "Quarterly" : "季度",
trialBadge: isEn ? "3-day trial" : "3天试用",
trialPaidGroupLocked: isEn