import { useTranslation } from "react-i18next";
import { Form, Link } from "react-router";
import { FeatherAlertTriangle, FeatherArrowRight, FeatherCreditCard, FeatherLockKeyhole, FeatherRefreshCw, FeatherUsers } from "@subframe/core";
import type { AdminBillingRow, AdminBillingStatus, AdminBillingVM } from "@hivegrid/view-models";
import { BadgeFeedback } from "~/ui/components/BadgeFeedback";
import { BannerAlert } from "~/ui/components/BannerAlert";
import { Button } from "~/ui/components/Button";
import { Card } from "~/ui/components/Card";
import { EmptyState } from "~/ui/components/EmptyState";
import { NumberInput } from "~/ui/components/NumberInput";
import { StatsCard } from "~/ui/components/StatsCard";
import { TextInput } from "~/ui/components/TextInput";
import { adminPath } from "~/utils/app/CanonicalUrlUtils";
import { planCodeLabel } from "./adminEnumLabels";
export type AdminBillingPageProps = {
vm: AdminBillingVM;
csrf: string;
submitting: boolean;
feedback?: { success?: string; error?: string };
};
/** D-ADMIN S05: Lago/Mollie and entitlement administration interim screen. */
export function AdminBillingPage({ vm, csrf, submitting, feedback }: AdminBillingPageProps): React.JSX.Element {
const { t } = useTranslation();
const ready = vm.status === "ready" ? vm.data : null;
return (
{feedback?.success ?
{feedback.success} : null}
{feedback?.error ?
{feedback.error} : null}
{vm.status === "empty" ? (
) : vm.status === "error" ? (
) : ready ? (
<>
{ready.rows.map((row) => )}
>
) :
}
);
}
function BillingSummary({ summary }: { summary: NonNullable["summary"] }): React.JSX.Element {
const { t } = useTranslation();
return (
} />
} />
} />
} />
} />
);
}
function BillingTenantCard({ row, csrf, submitting }: { row: AdminBillingRow; csrf: string; submitting: boolean }): React.JSX.Element {
const { t } = useTranslation();
return (
{row.tenantName}
/{row.tenantSlug}
{t(row.statusLabelKey)}
{t(row.planKindLabelKey)}
{row.readOnly ? {t("admin.billing.summary.readOnly")} : null}
{t("admin.billing.providers.lago")}
{t("admin.billing.providers.mollie")}
{/* `/accounts` renders the same plan as "Business"; this view printed the raw `business` (audit I18N-02). */}
{t("admin.billing.overrideNotice")}
{/* NumberInput is a fixed 192px-wide component — the seats column must match or the stepper gets overlapped. */}
{(["lago", "mollie"] as const).map((provider) => (
))}
}>{t("admin.billing.links.audit")}
}>{t("admin.billing.links.users")}
);
}
function Value({ label, value }: { label: string; value: string | number | null }): React.JSX.Element {
return {label}{value || "-"}
;
}
function statusTone(status: AdminBillingStatus): "subtle-positive" | "subtle-warning" | "subtle-negative" | "subtle-information" {
if (status === "active") return "subtle-positive";
if (status === "cancelled") return "subtle-negative";
if (status === "past_due" || status === "frozen") return "subtle-warning";
return "subtle-information";
}