feat(tip): add selectable coffee gift tiers

This commit is contained in:
2026-07-15 17:00:25 +08:00
parent e1a43a641b
commit c277b3e6ca
16 changed files with 480 additions and 98 deletions
+40 -10
View File
@@ -1,38 +1,68 @@
import { ROUTES } from "@/router/routes";
export const TIP_COFFEE_TYPE_PARAM = "coffee_type";
export const DEFAULT_TIP_COFFEE_TYPE = "small";
export const DEFAULT_TIP_COFFEE_TYPE = "medium";
export type TipCoffeeType = "small" | "medium" | "large";
export interface TipCoffeeOption {
type: TipCoffeeType;
amountCents: number;
fallbackName: string;
planId: string;
readonly type: TipCoffeeType;
readonly tierLabel: string;
readonly amountCents: number;
readonly displayName: string;
readonly image: {
readonly src: string;
readonly width: number;
readonly height: number;
};
readonly planId: string;
}
const TIP_COFFEE_OPTIONS: Record<TipCoffeeType, TipCoffeeOption> = {
const TIP_COFFEE_OPTION_BY_TYPE: Record<TipCoffeeType, TipCoffeeOption> = {
small: {
type: "small",
tierLabel: "Small",
amountCents: 499,
fallbackName: "Small Coffee",
displayName: "Velvet Espresso",
image: {
src: "/images/tip/small.jpg",
width: 736,
height: 736,
},
planId: "tip_coffee_usd_4_99",
},
medium: {
type: "medium",
tierLabel: "Medium",
amountCents: 999,
fallbackName: "Medium Coffee",
displayName: "Golden Reserve",
image: {
src: "/images/tip/medium.png",
width: 1024,
height: 1024,
},
planId: "tip_coffee_usd_9_99",
},
large: {
type: "large",
tierLabel: "Large",
amountCents: 1999,
fallbackName: "Large Coffee",
displayName: "Imperial Grand Cru",
image: {
src: "/images/tip/large.png",
width: 1024,
height: 1024,
},
planId: "tip_coffee_usd_19_99",
},
};
export const TIP_COFFEE_OPTIONS: readonly TipCoffeeOption[] = [
TIP_COFFEE_OPTION_BY_TYPE.small,
TIP_COFFEE_OPTION_BY_TYPE.medium,
TIP_COFFEE_OPTION_BY_TYPE.large,
];
export function resolveTipCoffeeType(
value: string | null | undefined,
): TipCoffeeType | null {
@@ -48,7 +78,7 @@ export function resolveTipCoffeeType(
}
export function getTipCoffeeOption(type: TipCoffeeType): TipCoffeeOption {
return TIP_COFFEE_OPTIONS[type];
return TIP_COFFEE_OPTION_BY_TYPE[type];
}
export function buildTipCoffeePath(type: TipCoffeeType): string {