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 }[] = []; if (plan.limits.max_servers !== next.limits.max_servers) rows.push({ field: "max_servers", was: limitLabel(plan.limits.max_servers), now: limitLabel(next.limits.max_servers), }); if (plan.limits.max_secret_groups !== next.limits.max_secret_groups) rows.push({ field: "max_secret_groups", was: limitLabel(plan.limits.max_secret_groups), now: limitLabel(next.limits.max_secret_groups), }); if (plan.limits.max_channels !== next.limits.max_channels) rows.push({ field: "max_channels", was: limitLabel(plan.limits.max_channels), now: limitLabel(next.limits.max_channels), }); if (plan.features.join(",") !== next.features.join(",")) rows.push({ field: "features", was: plan.features.join(", ") || "none", now: next.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.

); }