import { Lock, Sparkles } from 'lucide-react' import { Link } from 'react-router-dom' import { cn } from '@/lib/utils' interface UpgradePromptProps { feature: string className?: string } interface FeatureMeta { /** Display name shown in the prompt heading. */ displayName: string /** Plan that unlocks this feature. */ requiredPlan: string /** Optional one-line value pitch. */ description?: string } /** * Mapping from feature flag key to display metadata. * * v1: small inline table maintained here. If this grows, lift to * `frontend/src/lib/featureCatalog.ts` and source from a backend endpoint. * * Keys must match `feature_flags.flag_key` on the backend. */ const FEATURE_CATALOG: Record = { psa_integration: { displayName: 'PSA Integration', requiredPlan: 'Pro', description: 'Sync tickets and assets with your PSA in real time.', }, kb_accelerator: { displayName: 'Knowledge Base Accelerator', requiredPlan: 'Pro', description: 'Auto-generate troubleshooting flows from your existing KB.', }, ai_builder: { displayName: 'AI Builder', requiredPlan: 'Pro', description: 'Generate decision trees from natural-language prompts.', }, branching_logic: { displayName: 'Branching Logic', requiredPlan: 'Pro', }, custom_branding: { displayName: 'Custom Branding', requiredPlan: 'Pro', }, api_access: { displayName: 'API Access', requiredPlan: 'Pro', }, sso: { displayName: 'Single Sign-On', requiredPlan: 'Enterprise', }, } /** Humanize an unknown feature key for the fallback display name. */ function humanizeFeatureKey(key: string): string { return key .split('_') .map((part) => part.charAt(0).toUpperCase() + part.slice(1)) .join(' ') } /** * Standardized "this feature is on Pro" affordance. * * Renders a locked panel with a CTA that routes to the plan-selection page. * The actual gating is enforced server-side via `require_feature` — this is UX. */ export function UpgradePrompt({ feature, className }: UpgradePromptProps) { const meta = FEATURE_CATALOG[feature] const displayName = meta?.displayName ?? humanizeFeatureKey(feature) const requiredPlan = meta?.requiredPlan ?? 'Pro' const description = meta?.description return (

{displayName} is available on {requiredPlan}

{description && (

{description}

)}
) } export default UpgradePrompt