fix(tip): refine gift presentation

This commit is contained in:
2026-07-21 14:24:26 +08:00
parent 37ff69020b
commit a990f5082b
6 changed files with 45 additions and 31 deletions
+12 -1
View File
@@ -5,6 +5,12 @@ import type {
export const TIP_GIFT_PLACEHOLDER_IMAGE = "/images/tip/medium.png";
const TIP_GIFT_PLACEHOLDER_BY_TIP_TYPE: Readonly<Record<string, string>> = {
coffee_small: "/images/tip/small.jpg",
coffee_medium: "/images/tip/medium.png",
coffee_large: "/images/tip/large.png",
};
export function formatGiftPrice(
amountCents: number,
currency: string,
@@ -25,10 +31,15 @@ export function getGiftImageSources(
product: GiftProduct | null,
category: GiftCategory | null,
): readonly string[] {
const placeholderImage = product
? (TIP_GIFT_PLACEHOLDER_BY_TIP_TYPE[product.tipType] ??
TIP_GIFT_PLACEHOLDER_IMAGE)
: TIP_GIFT_PLACEHOLDER_IMAGE;
return [
product?.imageUrl,
category?.imageUrl,
TIP_GIFT_PLACEHOLDER_IMAGE,
placeholderImage,
].filter(
(source, index, sources): source is string =>
Boolean(source) && sources.indexOf(source) === index,