1834b97fe2
PR Check / Lint, Check, Test and Build (push) Has been cancelled
Squash merge of fix/134-促销前端展示对齐 (4702dee).
HIF-79/HIF-113 落地后前端有三处对齐缺失:
- promo-info.tsx 仍读 promo.end_time,但后端 SubscribeDiscountPromo
JSON 字段是 expires_at(×2 处)
- billing.tsx 缺 Promo Discount 行,PreOrderResponse 拿到 promo_discount
时无处可渲染
- typings.d.ts: SubscribeDiscountPromo 缺 expires_at/rule_type,
PreOrderResponse 缺 promo_discount
本次仅修字段对齐与展示行,不动业务逻辑、不动 OrderDetail 类型 (后端
当前未透出 promo_discount)。新增 billing.promoDiscount 中英文文案。
34 lines
1.0 KiB
TypeScript
34 lines
1.0 KiB
TypeScript
import { Badge } from "@workspace/ui/components/badge";
|
|
import { useTranslation } from "react-i18next";
|
|
import { Display } from "@/components/display";
|
|
|
|
interface PromoInfoProps {
|
|
discount?: API.SubscribeDiscount;
|
|
}
|
|
|
|
export function PromoInfo({ discount }: Readonly<PromoInfoProps>) {
|
|
const { t } = useTranslation("subscribe");
|
|
const promo = discount?.promo;
|
|
|
|
if (!promo) return null;
|
|
|
|
return (
|
|
<div className="flex flex-wrap items-center justify-between gap-2 rounded-md border bg-muted/40 p-3 text-sm">
|
|
<div className="grid gap-1">
|
|
<span className="font-medium">
|
|
{promo.rule_name || t("promo.available", "Promo Available")}
|
|
</span>
|
|
{promo.expires_at && (
|
|
<span className="text-muted-foreground text-xs">
|
|
{t("promo.validUntil", "Valid until")}:{" "}
|
|
{new Date(promo.expires_at * 1000).toLocaleString()}
|
|
</span>
|
|
)}
|
|
</div>
|
|
<Badge variant="secondary">
|
|
<Display type="currency" value={promo.promo_price} />
|
|
</Badge>
|
|
</div>
|
|
);
|
|
}
|