fix(tip): refine gift presentation
This commit is contained in:
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user