Gate checkout overlay by subscription recovery eligibility

This commit is contained in:
2569718930@qq.com
2026-04-10 09:00:37 +08:00
parent 150c793b35
commit 15022c77c0
+33 -23
View File
@@ -1482,6 +1482,11 @@ export function AccountCenter() {
const showExpiringSoon = const showExpiringSoon =
Boolean(isSubscribed && expiryInfo && !expiryInfo.expired && expiryInfo.daysLeft <= 3); Boolean(isSubscribed && expiryInfo && !expiryInfo.expired && expiryInfo.daysLeft <= 3);
const showExpiredReminder = Boolean(!isSubscribed && expiryInfo && expiryInfo.expired); const showExpiredReminder = Boolean(!isSubscribed && expiryInfo && expiryInfo.expired);
const paymentFeatureReady = paymentReadyForRecovery;
const canOpenCheckoutOverlay = Boolean(
paymentFeatureReady &&
(!isSubscribed || showExpiringSoon || showExpiredReminder),
);
const subscriptionStatusTitle = showExpiredReminder const subscriptionStatusTitle = showExpiredReminder
? isTrialPlan ? isTrialPlan
? copy.trialExpiredTitle ? copy.trialExpiredTitle
@@ -1506,7 +1511,7 @@ export function AccountCenter() {
: ""; : "";
useEffect(() => { useEffect(() => {
if (!showOverlay || isSubscribed) return; if (!showOverlay || !canOpenCheckoutOverlay) return;
trackAppEvent("paywall_viewed", { trackAppEvent("paywall_viewed", {
entry: "account_center", entry: "account_center",
user_state: isAuthenticated ? "logged_in" : "guest", user_state: isAuthenticated ? "logged_in" : "guest",
@@ -1516,12 +1521,12 @@ export function AccountCenter() {
}); });
}, [ }, [
isAuthenticated, isAuthenticated,
isSubscribed, canOpenCheckoutOverlay,
planCode, planCode,
showExpiredReminder, showExpiredReminder,
showExpiringSoon, showExpiringSoon,
showOverlay, showOverlay,
]); ]);
// Points Logic // Points Logic
const backendPointsRaw = Number(backend?.points); const backendPointsRaw = Number(backend?.points);
@@ -1615,9 +1620,6 @@ export function AccountCenter() {
(resolvedSelectedTokenAddress.startsWith("0x") (resolvedSelectedTokenAddress.startsWith("0x")
? shortAddress(resolvedSelectedTokenAddress) ? shortAddress(resolvedSelectedTokenAddress)
: "USDC"); : "USDC");
const paymentFeatureReady = Boolean(
paymentConfig?.enabled && paymentConfig?.configured,
);
const paymentReceiverAddress = String( const paymentReceiverAddress = String(
selectedPaymentToken?.receiver_contract || selectedPaymentToken?.receiver_contract ||
paymentConfig?.receiver_contract || paymentConfig?.receiver_contract ||
@@ -2397,15 +2399,17 @@ export function AccountCenter() {
</div> </div>
</div> </div>
<div className="flex items-center gap-2"> <div className="flex items-center gap-2">
{!isSubscribed && !showOverlay && paymentFeatureReady && ( {!showOverlay && canOpenCheckoutOverlay && (
<button <button
onClick={() => setShowOverlay(true)} onClick={() => setShowOverlay(true)}
className="flex items-center gap-2 px-4 py-2 bg-yellow-500/10 hover:bg-yellow-500/20 border border-yellow-500/30 text-yellow-500 rounded-xl text-sm transition-all animate-pulse" className="flex items-center gap-2 px-4 py-2 bg-yellow-500/10 hover:bg-yellow-500/20 border border-yellow-500/30 text-yellow-500 rounded-xl text-sm transition-all animate-pulse"
> >
<Crown size={16} />{" "} <Crown size={16} />{" "}
{showExpiredReminder ? copy.renewNow : copy.upgradePro} {showExpiringSoon || showExpiredReminder
</button> ? copy.renewNow
)} : copy.upgradePro}
</button>
)}
<button <button
type="button" type="button"
onClick={() => void onRefresh()} onClick={() => void onRefresh()}
@@ -2454,6 +2458,12 @@ export function AccountCenter() {
{subscriptionStatusMeta} {subscriptionStatusMeta}
</p> </p>
) : null} ) : null}
{billing.canRedeem ? (
<p className="mt-2 text-xs text-emerald-200/90">
{billing.pointsUsed} ${billing.discountAmount.toFixed(2)}
</p>
) : null}
</div> </div>
<button <button
type="button" type="button"
@@ -2605,9 +2615,9 @@ export function AccountCenter() {
{/* Subscription Info & Paywall */} {/* Subscription Info & Paywall */}
<div className="lg:col-span-12 relative"> <div className="lg:col-span-12 relative">
<div <div
className={`grid grid-cols-1 md:grid-cols-2 gap-6 transition-all duration-700 ${!isSubscribed && showOverlay ? "blur-md grayscale-[0.3] opacity-30 select-none pointer-events-none" : ""}`} className={`grid grid-cols-1 md:grid-cols-2 gap-6 transition-all duration-700 ${canOpenCheckoutOverlay && showOverlay ? "blur-md grayscale-[0.3] opacity-30 select-none pointer-events-none" : ""}`}
> >
<section className="bg-white/5 border border-white/10 rounded-[2rem] p-6 space-y-3"> <section className="bg-white/5 border border-white/10 rounded-[2rem] p-6 space-y-3">
<h3 className="text-sm font-bold text-blue-400 uppercase tracking-widest mb-4"> <h3 className="text-sm font-bold text-blue-400 uppercase tracking-widest mb-4">
{copy.membershipDetails} {copy.membershipDetails}
@@ -2670,7 +2680,7 @@ export function AccountCenter() {
</div> </div>
{/* Paywall Mask */} {/* Paywall Mask */}
{!isSubscribed && showOverlay && ( {canOpenCheckoutOverlay && showOverlay && (
<div className="absolute inset-0 z-30 flex items-center justify-center p-4"> <div className="absolute inset-0 z-30 flex items-center justify-center p-4">
<UnlockProOverlay <UnlockProOverlay
points={totalPoints} points={totalPoints}