import Stack from "@mui/material/Stack"; import Typography from "@mui/material/Typography"; import Chip from "@mui/material/Chip"; import { Button } from "@/components/inputs"; import { BaseBox } from "@/components/design-elements"; import { PersonStanding, BicepsFlexed, Building2, Briefcase, Check, } from "lucide-react"; import Divider from "@mui/material/Divider"; import Tooltip from "@mui/material/Tooltip"; import { useTheme } from "@mui/material/styles"; import type { Entitlements, PlanKey } from "@/types/entitlements"; import { useTranslation } from "react-i18next"; export const PlanCard = ({ plan, currentPlan, onClick, loading, }: { plan: Entitlements; currentPlan: PlanKey | null; onClick?: (planKey: PlanKey) => void; loading?: boolean; }) => { const { t } = useTranslation(); const selected = plan.plan === currentPlan; const theme = useTheme(); const checkColor = plan.plan === "enterprise" ? theme.palette.success.main : plan.plan === "free" ? theme.palette.text.secondary : theme.palette.primary.main; const Icon = (() => { switch (plan.plan) { case "free": return PersonStanding; case "pro": return BicepsFlexed; case "business": return Briefcase; case "enterprise": return Building2; default: return PersonStanding; } })(); const priceLabel = (() => { if (typeof plan.price === "number") { const cents = plan.price; if (cents === 0) return "Free"; const dollars = cents / 100; const formatted = dollars.toFixed(2); return `$${formatted}/mo`; } })(); const featureItems = [ { label: t("billing.plans.features.monitors.title"), value: plan.monitorsMax, tooltip: t("billing.plans.features.monitors.toolTip"), }, { label: t("billing.plans.features.statusPages.title"), value: plan.statusPagesMax, tooltip: t("billing.plans.features.statusPages.toolTip"), }, { label: t("billing.plans.features.notificationChannels.title"), value: plan.notificationChannelsMax, tooltip: t("billing.plans.features.notificationChannels.toolTip"), }, { label: t("billing.plans.features.teams.title"), value: plan.teamsMax, tooltip: t("billing.plans.features.teams.toolTip"), }, { label: t("billing.plans.features.retention.title"), value: `${plan.retentionDays} days`, tooltip: t("billing.plans.features.retention.toolTip"), }, { label: t("billing.plans.features.interval.title"), value: `${Math.round(plan.checksIntervalMsMin / 1000)}s`, tooltip: t("billing.plans.features.interval.toolTip"), }, ]; return ( onClick?.(plan.plan)} > {plan.plan} {plan.plan === "pro" && ( )} {priceLabel} {featureItems.map((item) => ( {item.tooltip ? ( {item.label}: {item.value} ) : ( {item.label}: {item.value} )} ))} {selected ? null : ( // )} ); };