Skip to content

fix(dashboard): say whether the day count is remaining or overdue - #169

Merged
Ember-Moth merged 1 commit into
perfect-panel:developfrom
echoowall:fix/expiry-days-label
Aug 14, 2026
Merged

fix(dashboard): say whether the day count is remaining or overdue#169
Ember-Moth merged 1 commit into
perfect-panel:developfrom
echoowall:fix/expiry-days-label

Conversation

@echoowall

Copy link
Copy Markdown
Contributor

问题

订阅卡片上这一格用同一个标签「Expiration Days / 过期天数」套在 Math.abs(...) 上:

// apps/user/src/sections/user/dashboard/content.tsx
<span className="text-muted-foreground">
  {t("expirationDays", "Expiration Days")}
</span>
<span className="font-semibold text-2xl">
  {item.expire_time
    ? Math.abs(differenceInDays(new Date(item.expire_time), new Date()))
    : t("noLimit", "No Limit")}
</span>

Math.abs 让两种相反的状态渲染出完全相同的结果:

实际情况 显示
还剩 47 天到期 47
已经过期 47 天 47

而标签本身也是双关的 —— 「过期天数」既可以理解成「距离过期还有几天」,也可以理解成「已经过期了几天」。数字和标题互相都无法消歧,用户按自己的预期去读,读到哪个全看运气。

这在实际运营中会造成反向效果:已过期的用户看到一个正数,以为自己还有时间,反而不会去续费。

改动

卡片本身已经为水印和 greyscale 计算了 isActuallyExpired,标签直接跟着它走:

{isActuallyExpired
  ? t("expiredDays", "Days Expired")
  : t("remainingDays", "Remaining Days")}

数值保留 Math.abs —— 方向已经由标签承担;去掉 abs 只会让已过期的重新显示负数,那正是它当初被加上的原因。

新增两个 key(zh-CN / en-US),移除不再被引用的 expirationDays

验证

bun --filter ppanel-user-web checkbun run build 均通过。

The subscription card renders one label, "Expiration Days", over
Math.abs(differenceInDays(expire_time, now)). The absolute value makes a
subscription with 47 days left and one that expired 47 days ago render the
identical "47", and the label reads equally well as "days until expiry" and
"days since expiry", so neither the number nor its caption resolves the other.
Users read it as whichever they expected.

The card already computes isActuallyExpired for its watermark and greyscale, so
the caption can follow it: Remaining Days before expiry, Days Expired after.
The value keeps Math.abs -- the caption now carries the direction, and dropping
the abs would only bring back the negative count that made it look broken.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@Ember-Moth
Ember-Moth merged commit 52bd6f8 into perfect-panel:develop Aug 14, 2026
1 check passed
@web-ppanel

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 1.15.1-dev.1 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants