|
| 1 | +import { Link } from "react-router-dom" |
| 2 | + |
| 3 | +const UPGRADE_MESSAGES = { |
| 4 | + nodes: { |
| 5 | + title: "Node Limit Reached", |
| 6 | + icon: "🖥️", |
| 7 | + description: "You've hit the maximum number of camera nodes on your current plan.", |
| 8 | + benefit: "Upgrade to connect more nodes and expand your security coverage.", |
| 9 | + }, |
| 10 | + cameras: { |
| 11 | + title: "Camera Limit Reached", |
| 12 | + icon: "📹", |
| 13 | + description: "You've reached the maximum number of cameras for your plan.", |
| 14 | + benefit: "Upgrade to monitor more cameras across all your locations.", |
| 15 | + }, |
| 16 | + admin: { |
| 17 | + title: "Pro Feature", |
| 18 | + icon: "📊", |
| 19 | + description: "The Admin Dashboard with stream access logs and analytics is a Pro feature.", |
| 20 | + benefit: "Upgrade to get full visibility into who's accessing your streams.", |
| 21 | + }, |
| 22 | + "danger-zone": { |
| 23 | + title: "Pro Feature", |
| 24 | + icon: "⚙️", |
| 25 | + description: "Advanced management tools like log wiping and full resets are Pro features.", |
| 26 | + benefit: "Upgrade for complete control over your organization data.", |
| 27 | + }, |
| 28 | +} |
| 29 | + |
| 30 | +const PLAN_COMPARISON = [ |
| 31 | + { label: "Cameras", free: "2", pro: "10", business: "50" }, |
| 32 | + { label: "Nodes", free: "1", pro: "5", business: "Unlimited" }, |
| 33 | + { label: "Admin Dashboard", free: false, pro: true, business: true }, |
| 34 | + { label: "Stream Analytics", free: false, pro: true, business: true }, |
| 35 | + { label: "Danger Zone Tools", free: false, pro: true, business: true }, |
| 36 | + { label: "Priority Support", free: false, pro: false, business: true }, |
| 37 | +] |
| 38 | + |
| 39 | +function UpgradeModal({ isOpen, onClose, feature, currentPlan }) { |
| 40 | + if (!isOpen) return null |
| 41 | + |
| 42 | + const msg = UPGRADE_MESSAGES[feature] || UPGRADE_MESSAGES.nodes |
| 43 | + const planName = currentPlan === "free_org" ? "Free" : currentPlan === "pro" ? "Pro" : "Business" |
| 44 | + |
| 45 | + return ( |
| 46 | + <div className="modal-overlay" onClick={onClose}> |
| 47 | + <div className="modal-content upgrade-modal" onClick={(e) => e.stopPropagation()}> |
| 48 | + <div className="modal-header"> |
| 49 | + <h2>{msg.title}</h2> |
| 50 | + <button className="modal-close" onClick={onClose}>×</button> |
| 51 | + </div> |
| 52 | + |
| 53 | + <div className="modal-body"> |
| 54 | + <div className="upgrade-modal-hero"> |
| 55 | + <div className="upgrade-modal-icon">{msg.icon}</div> |
| 56 | + <p className="upgrade-modal-desc">{msg.description}</p> |
| 57 | + <p className="upgrade-modal-benefit">{msg.benefit}</p> |
| 58 | + <div className="upgrade-modal-current"> |
| 59 | + Currently on the <strong>{planName}</strong> plan |
| 60 | + </div> |
| 61 | + </div> |
| 62 | + |
| 63 | + <div className="upgrade-comparison"> |
| 64 | + <table className="comparison-table"> |
| 65 | + <thead> |
| 66 | + <tr> |
| 67 | + <th></th> |
| 68 | + <th className={currentPlan === "free_org" ? "current-col" : ""}>Free</th> |
| 69 | + <th className={currentPlan === "pro" ? "current-col" : "highlight-col"}>Pro</th> |
| 70 | + <th className={currentPlan === "business" ? "current-col" : ""}>Business</th> |
| 71 | + </tr> |
| 72 | + </thead> |
| 73 | + <tbody> |
| 74 | + {PLAN_COMPARISON.map((row) => ( |
| 75 | + <tr key={row.label}> |
| 76 | + <td className="comparison-label">{row.label}</td> |
| 77 | + <td className={currentPlan === "free_org" ? "current-col" : ""}> |
| 78 | + {typeof row.free === "boolean" ? (row.free ? "✓" : "—") : row.free} |
| 79 | + </td> |
| 80 | + <td className={currentPlan === "pro" ? "current-col" : "highlight-col"}> |
| 81 | + {typeof row.pro === "boolean" ? (row.pro ? "✓" : "—") : row.pro} |
| 82 | + </td> |
| 83 | + <td className={currentPlan === "business" ? "current-col" : ""}> |
| 84 | + {typeof row.business === "boolean" ? (row.business ? "✓" : "—") : row.business} |
| 85 | + </td> |
| 86 | + </tr> |
| 87 | + ))} |
| 88 | + </tbody> |
| 89 | + </table> |
| 90 | + </div> |
| 91 | + |
| 92 | + <div className="modal-actions"> |
| 93 | + <button className="btn btn-secondary" onClick={onClose}> |
| 94 | + Maybe Later |
| 95 | + </button> |
| 96 | + <Link to="/pricing" className="btn btn-primary" onClick={onClose}> |
| 97 | + View Plans |
| 98 | + </Link> |
| 99 | + </div> |
| 100 | + </div> |
| 101 | + </div> |
| 102 | + </div> |
| 103 | + ) |
| 104 | +} |
| 105 | + |
| 106 | +export default UpgradeModal |
0 commit comments