import React from "react"; import { createPortal } from "react-dom"; import { Crown, X, Sparkles, CheckCircle2, ArrowRight, Zap, Play, } from "lucide-react"; import { __ } from "../../lib/i18n"; import { Card, CardContent, CardHeader, CardTitle, CardDescription, } from "../ui/card"; import { Button } from "../ui/button"; interface PremiumUpgradeDialogProps { open: boolean; onClose: () => void; moduleName?: string; /** Module slug — used to pick module-specific bullet copy. */ moduleSlug?: string; purchaseUrl?: string; moduleDescription?: string; /** * Required plan tier for this feature — drives the badge in the * header AND the CTA copy. When unset, the dialog falls back to * the generic "Yatra Pro" messaging. */ requiredPlan?: "personal" | "growth" | "agency"; } /** * Module-specific bullets shown in the "Key Features" list. Without * these we'd be stuck with the generic four-item placeholder * ("Advanced analytics and reporting", etc.) regardless of which * module the operator is looking at — confusing because the dialog * title already says "White Label" but the bullets say nothing about * branding. */ const MODULE_FEATURES: Record = { white_label: [ "Rebrand the plugin: name, logo, author, support URL", "Replace Yatra/MantraBrain references on plugin list + PDFs", "Custom admin menu labels, icons, ordering", "Custom brand color applied across the admin UI", ], "white-label": [ "Rebrand the plugin: name, logo, author, support URL", "Replace Yatra/MantraBrain references on plugin list + PDFs", "Custom admin menu labels, icons, ordering", "Custom brand color applied across the admin UI", ], ai_assistant: [ "Inline AI generation on trip descriptions, FAQs, SEO meta", "Multi-step agents for full trip + itinerary creation", "AI public chat widget on every single-trip page", "Bring your own OpenAI / Anthropic key — no per-call markup", ], "ai-assistant": [ "Inline AI generation on trip descriptions, FAQs, SEO meta", "Multi-step agents for full trip + itinerary creation", "AI public chat widget on every single-trip page", "Bring your own OpenAI / Anthropic key — no per-call markup", ], }; /** * Fallback bullets per plan tier when the module isn't in * MODULE_FEATURES yet. Tier-appropriate so a "Growth" module's * generic bullets don't accidentally mention Agency-only perks. */ const TIER_DEFAULT_FEATURES: Record = { agency: [ "Unlocks every premium module — Scale-tier and below", "Full white-label rebranding capability", "Priority support with faster response times", "All future Scale-tier features included", ], growth: [ "Advanced operator-productivity features", "AI assistant for content + itinerary generation", "Priority support included", "All future Growth-tier features included", ], personal: [ "Premium booking-system extensions", "Email automation + abandoned-recovery workflows", "Dynamic pricing + advanced discount tools", "All future Starter-tier features included", ], }; export const PremiumUpgradeDialog: React.FC = ({ open, onClose, moduleName, moduleSlug, purchaseUrl, moduleDescription, requiredPlan, }) => { if (!open) return null; // Resolve the customer-facing plan name from the tier slug. The // header badge + footer CTA both consume this so the operator // sees one consistent answer to "which plan do I need?". const planLabel = requiredPlan === "agency" ? __("Scale plan", "yatra") : requiredPlan === "growth" ? __("Growth plan", "yatra") : requiredPlan === "personal" ? __("Starter plan", "yatra") : null; const planCtaLabel = requiredPlan === "agency" ? __("Upgrade to Scale", "yatra") : requiredPlan === "growth" ? __("Upgrade to Growth", "yatra") : requiredPlan === "personal" ? __("Upgrade to Starter", "yatra") : __("Upgrade to Pro", "yatra"); const planFooterCopy = requiredPlan === "agency" ? __( "This feature is exclusive to the Scale plan. Upgrade to unlock it.", "yatra", ) : requiredPlan === "growth" ? __( "This feature unlocks on the Growth plan (or Scale). Upgrade to enable it.", "yatra", ) : requiredPlan === "personal" ? __( "This feature is included on every Pro plan. Upgrade to unlock it.", "yatra", ) : __("Upgrade to Yatra Pro and unlock this feature today", "yatra"); // Module-specific bullets first; fall back to tier-appropriate // defaults; finally fall back to the very generic Pro bullets so // the section never renders empty. const features: string[] = (moduleSlug && MODULE_FEATURES[moduleSlug]) || (requiredPlan && TIER_DEFAULT_FEATURES[requiredPlan]) || [ __("Advanced analytics and reporting", "yatra"), __("Automated workflows and notifications", "yatra"), __("Enhanced customer management tools", "yatra"), __("Priority support and updates", "yatra"), ]; return createPortal(
{/* Subtle premium glow */}
{/* Premium accent bar */}
{moduleName || __("Premium Feature", "yatra")} {/* Plan-tier badge so the operator immediately knows which license unlocks this. Without it the generic "Premium Feature" copy was ambiguous — Growth and Scale are both premium but cost different amounts. */} {planLabel && ( {planLabel} )}
{moduleDescription || __( "This feature requires Yatra Pro to unlock powerful premium capabilities.", "yatra", )}
{/* Left Side - Module Description */}

{__("What This Module Does", "yatra")}

{moduleDescription || __( "This premium module adds advanced functionality to your Yatra booking system, helping you grow your business and streamline operations.", "yatra", )}

{/* Feature List — module-specific bullets so the operator sees exactly what they're getting, not a generic placeholder list. */}

{__("Key Features", "yatra")}

    {features.map((line, i) => (
  • {line}
  • ))}
{/* Right Side - Video Preview */}

{__("See It In Action", "yatra")}

{__("Click to watch demo video", "yatra")}

{planFooterCopy}

, document.body, ); };