diff --git a/src/App.tsx b/src/App.tsx index 090b762..ced1bc8 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -938,20 +938,6 @@ export default function App() { window.history.pushState({ paymentCompleted: true }, document.title, window.location.href); } - if (/Android|iPhone|iPad|iPod/i.test(navigator.userAgent)) { - setTimeout(() => { - if (/Android/i.test(navigator.userAgent)) { - // Use Android Intent format to avoid blocked navigation in Android Chrome - window.location.href = 'intent://#Intent;scheme=acupedia;package=com.anonymous.acupedia;end'; - setTimeout(() => { - window.location.href = 'acupedia://'; - }, 500); - } else { - window.location.href = 'acupedia://'; - } - }, 1500); - } - setCart([]); setAppliedCoupon(null); await fetchUserProfile(userToken); diff --git a/src/components/cart/CartDrawer.tsx b/src/components/cart/CartDrawer.tsx index 5cc51b9..9fc9ae2 100644 --- a/src/components/cart/CartDrawer.tsx +++ b/src/components/cart/CartDrawer.tsx @@ -216,6 +216,18 @@ export const CartDrawer: React.FC = ({ : `$${activePricing.base_subtotal}`} + {activePricing.renewal_discount_amount > 0 && ( +
+ Early Renewal Discount (20%) + + -{currency === 'INR' + ? `₹${activePricing.renewal_discount_amount}` + : currency === 'EUR' + ? `€${activePricing.renewal_discount_amount}` + : `$${activePricing.renewal_discount_amount}`} + +
+ )} {activePricing.bundle_discount_amount > 0 && (
@@ -247,6 +259,7 @@ export const CartDrawer: React.FC = ({
)} {activePricing.total_discounts > 0 && + !activePricing.renewal_discount_amount && !activePricing.bundle_discount_amount && !activePricing.coupon_discount_amount && (
diff --git a/src/components/checkout/PaymentSuccessModal.tsx b/src/components/checkout/PaymentSuccessModal.tsx index e005c17..6e2ed33 100644 --- a/src/components/checkout/PaymentSuccessModal.tsx +++ b/src/components/checkout/PaymentSuccessModal.tsx @@ -1,7 +1,7 @@ -import React, { useState } from 'react'; -import { XCircle, CheckCircle, Check, Download, RefreshCw, Smartphone } from 'lucide-react'; +import React, { useState, useEffect } from 'react'; +import { XCircle, CheckCircle, Check, Download, RefreshCw, Smartphone, PauseCircle } from 'lucide-react'; import type { VerificationResult, UserProfile } from '../../types'; -import { openMobileApp, getAppDeepLinkUrls } from '../../utils/navigation'; +import { formatDeepLinkRoute } from '../../utils/navigation'; interface PaymentSuccessModalProps { verificationResult: VerificationResult; @@ -23,18 +23,83 @@ export const PaymentSuccessModal: React.FC = ({ appScheme, }) => { const [desktopNotice, setDesktopNotice] = useState(false); + const [countdown, setCountdown] = useState(10); + const [isRedirectCancelled, setIsRedirectCancelled] = useState(false); + const [isRedirecting, setIsRedirecting] = useState(false); - // Handler to reliably launch the Acupedia Mobile App across platforms - const handleOpenApp = (e: React.MouseEvent) => { - e.preventDefault(); - openMobileApp({ route: returnRoute, schemes: appScheme ? [appScheme] : undefined }); + // Enable 10-second auto-redirect countdown tile across all devices (iOS, Android, and web testing) + const showCountdown = true; + const route = formatDeepLinkRoute(returnRoute || 'modules'); + // Launch mobile app across iOS, Android, and Desktop + const launchMobileApp = () => { + setIsRedirecting(true); const userAgent = navigator.userAgent || ''; - const isMobile = /Android|iPhone|iPad|iPod/i.test(userAgent); - if (!isMobile) { + const isAndroid = /Android/i.test(userAgent); + const isIOS = /iPhone|iPad|iPod/i.test(userAgent); + + if (isAndroid) { + // Android Intent format for Chrome / modern Android browsers + const intentUrl = `intent://${route}#Intent;scheme=acupedia;package=com.anonymous.acupedia;end`; + window.location.href = intentUrl; + + setTimeout(() => { + window.location.href = `acupedia://${route}`; + }, 500); + setTimeout(() => { + window.location.href = `myapp://${route}`; + }, 1000); + } else if (isIOS) { + // iOS Safari and Chrome handle custom URI schemes directly + const primaryScheme = appScheme || 'acupedia'; + window.location.href = `${primaryScheme}://${route}`; + + // Fallback in case alternate scheme was registered in Expo + setTimeout(() => { + window.location.href = `acupedia://${route}`; + }, 400); + setTimeout(() => { + window.location.href = `myapp://${route}`; + }, 900); + } else { + // Desktop + window.location.href = `acupedia://${route}`; setDesktopNotice(true); } }; + + // 10-second auto-redirect countdown for mobile & web app testing + useEffect(() => { + if (!showCountdown || isRedirectCancelled || isRedirecting) return; + + if (countdown <= 0) { + launchMobileApp(); + return; + } + + const timer = setInterval(() => { + setCountdown((prev) => { + if (prev <= 1) { + clearInterval(timer); + launchMobileApp(); + return 0; + } + return prev - 1; + }); + }, 1000); + + return () => clearInterval(timer); + }, [countdown, showCountdown, isRedirectCancelled, isRedirecting]); + + const handleDownloadInvoiceClick = () => { + setIsRedirectCancelled(true); + onDownloadInvoice(verificationResult.paymentId || '', verificationResult.invoiceUrl); + }; + + const handleClose = () => { + setIsRedirectCancelled(true); + onClose(); + }; return (
@@ -43,7 +108,7 @@ export const PaymentSuccessModal: React.FC = ({ {/* Close button */}
+ {/* 📱 10-Second Auto-Redirect Tile */} + {showCountdown && !isRedirectCancelled && ( +
+
+
+
+ +
+
+

+ Returning to Acupedia App + + {countdown}s + +

+

+ Redirecting automatically if no action taken +

+
+
+ + +
+ + {/* Countdown progress bar */} +
+
+
+
+ )} + + {/* Banner shown if redirect is cancelled */} + {showCountdown && isRedirectCancelled && ( +
+ + + Auto-redirect paused. Take your time to download your invoice. + + +
+ )} + {/* Content: Mobile App Access Onboarding */} -
+

Your subscription entitlements are active! Access your content inside the{' '} Acupedia Mobile App. Log in with:{' '} @@ -82,14 +206,14 @@ export const PaymentSuccessModal: React.FC = ({ e.preventDefault()} - className="flex items-center gap-2 bg-slate-900 hover:bg-slate-800 text-white px-3.5 py-2 rounded-lg border border-slate-800 hover:border-slate-700 transition-all duration-300 shadow-sm group" + className="flex items-center gap-2 bg-slate-900 hover:bg-slate-800 text-white px-3 py-1.5 rounded-lg border border-slate-800 hover:border-slate-700 transition-all duration-300 shadow-sm group" > - +

@@ -97,14 +221,14 @@ export const PaymentSuccessModal: React.FC = ({ e.preventDefault()} - className="flex items-center gap-2 bg-slate-900 hover:bg-slate-800 text-white px-3.5 py-2 rounded-lg border border-slate-800 hover:border-slate-700 transition-all duration-300 shadow-sm group" + className="flex items-center gap-2 bg-slate-900 hover:bg-slate-800 text-white px-3 py-1.5 rounded-lg border border-slate-800 hover:border-slate-700 transition-all duration-300 shadow-sm group" > - +
-

Get it on

-

Google Play

+

Get it on

+

Google Play

@@ -120,14 +244,9 @@ export const PaymentSuccessModal: React.FC = ({ {verificationResult.invoiceNumber && ( {desktopNotice && (
@@ -212,8 +325,8 @@ export const PaymentSuccessModal: React.FC = ({ )} diff --git a/src/types/index.ts b/src/types/index.ts index 13bbb7e..1d7ce6b 100644 --- a/src/types/index.ts +++ b/src/types/index.ts @@ -9,6 +9,7 @@ export interface ModuleItem { priceEur: number; desc: string; color: string; + isRenewal?: boolean; } export interface UserSubscription { @@ -54,6 +55,7 @@ export interface PricingCalculation { grand_total: number; total_amount?: number; currency: Currency; + renewal_discount_amount?: number; coupon_applied?: string; coupon_discount_amount?: number; coupon_error?: string | null;