import type { Plan } from "@/lib/api"; import { limitLabel } from "@/lib/format"; import { Button } from "./Button"; /* * Editing a plan changes what every future customer gets, so the confirmation * names each field rather than asking "are you sure". Existing licences * snapshotted their plan at issue time and are genuinely unaffected — saying so * is what stops a well-meaning edit being followed by a panicked reissue. */ export function ConfirmPlanChange({ plan, next, issuedCount, onConfirm, onCancel, }: { plan: Plan; next: Plan; issuedCount: number; onConfirm: () => void; onCancel: () => void; }) { const rows: { field: string; was: string; now: string }[] = []; const fields = [ "max_servers", "max_monitors", "max_secret_groups", "max_channels", "audit_retention_days", ] as const; for (const f of fields) { if (plan.base_limits[f] !== next.base_limits[f]) rows.push({ field: f, was: limitLabel(plan.base_limits[f]), now: limitLabel(next.base_limits[f]), }); } if (plan.support_level !== next.support_level) rows.push({ field: "support_level", was: plan.support_level || "none", now: next.support_level || "none", }); if (plan.base_features.join(",") !== next.base_features.join(",")) rows.push({ field: "features", was: plan.base_features.join(", ") || "none", now: next.base_features.join(", ") || "none", }); return (

Change what {plan.name} grants?

This applies to licences issued from now on. The {issuedCount} licences already issued keep what they were signed with until each is reissued.

); }