fix(payment): consume first recharge offer after payment
This commit is contained in:
@@ -157,17 +157,17 @@ export function getDefaultSubscriptionPlanId(input: {
|
||||
|
||||
export function getFirstRechargeOfferView(input: {
|
||||
isFirstRecharge: boolean;
|
||||
discountPercent?: number | null;
|
||||
vipPlans: readonly VipOfferPlanView[];
|
||||
coinPlans: readonly CoinsOfferPlanView[];
|
||||
}): FirstRechargeOfferView | null {
|
||||
if (!input.isFirstRecharge) return null;
|
||||
|
||||
const promotedPlan = [...input.vipPlans, ...input.coinPlans].find(
|
||||
(plan) => plan.isFirstRechargeOffer,
|
||||
);
|
||||
if (!input.isFirstRecharge && !promotedPlan) return null;
|
||||
|
||||
const discountPercent =
|
||||
promotedPlan?.firstRechargeDiscountPercent ?? input.discountPercent ?? 50;
|
||||
promotedPlan?.firstRechargeDiscountPercent ?? 50;
|
||||
const badgeText = `${discountPercent}% OFF`;
|
||||
return {
|
||||
badgeText,
|
||||
|
||||
Reference in New Issue
Block a user