Refresh HiveGrid Cloud reference snapshot
This commit is contained in:
1 parent
5e99e14772
commit
7f88026f79
5955 files changed
+1177325
-188362
No files matched your search
+140
@@ -0,0 +1,140 @@
|
||||
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 (
|
||||
<div data-ui-id="ui.admin.billing.page" className="flex w-full flex-col items-start bg-surface-neutral-primary">
|
||||
<header className="flex w-full items-start gap-4 border-b border-solid border-border-default bg-surface-neutral-secondary px-6 py-5 mobile:px-4">
|
||||
<div className="flex grow shrink-0 basis-0 flex-col items-start">
|
||||
<h1 className="text-subtitle font-subtitle text-text-neutral-primary">{t("admin.billing.title")}</h1>
|
||||
<p className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">{t("admin.billing.description")}</p>
|
||||
</div>
|
||||
</header>
|
||||
{feedback?.success ? <BannerAlert type="success" fillContainer>{feedback.success}</BannerAlert> : null}
|
||||
{feedback?.error ? <BannerAlert type="error" fillContainer>{feedback.error}</BannerAlert> : null}
|
||||
<div className="flex w-full flex-col items-start gap-6 px-6 py-6 mobile:px-4">
|
||||
{vm.status === "empty" ? (
|
||||
<EmptyState outlined title={t("admin.billing.empty.headline")} body={t("admin.billing.empty.body")} />
|
||||
) : vm.status === "error" ? (
|
||||
<EmptyState variant="error" outlined title={t("admin.billing.title")} body={t(vm.error.messageKey)} />
|
||||
) : ready ? (
|
||||
<>
|
||||
<BillingSummary summary={ready.summary} />
|
||||
<div className="flex w-full flex-col items-start gap-4">
|
||||
{ready.rows.map((row) => <BillingTenantCard key={row.tenantId} row={row} csrf={csrf} submitting={submitting} />)}
|
||||
</div>
|
||||
</>
|
||||
) : <EmptyState outlined title={t("admin.billing.empty.headline")} body={t("admin.billing.empty.body")} />}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BillingSummary({ summary }: { summary: NonNullable<AdminBillingVM["data"]>["summary"] }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<div className="grid w-full grid-cols-5 gap-4 mobile:grid-cols-1">
|
||||
<StatsCard label={t("admin.billing.summary.attention.title")} value={summary.attentionCount} trend={summary.attentionCount ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherAlertTriangle />} />
|
||||
<StatsCard label={t("admin.billing.summary.readOnlyTitle")} value={summary.readOnlyCount} trend={summary.readOnlyCount ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherLockKeyhole />} />
|
||||
<StatsCard label={t("admin.billing.summary.providers.title")} value={summary.missingProviderCount} trend={summary.missingProviderCount ? "negative" : "positive"} percentage="" comparisonText="" icon={<FeatherRefreshCw />} />
|
||||
<StatsCard label={t("admin.billing.summary.enterprise.title")} value={summary.enterpriseCount + summary.customCount} trend="neutral" percentage="" comparisonText="" icon={<FeatherCreditCard />} />
|
||||
<StatsCard label={t("admin.billing.summary.seats.title")} value={summary.totalSeats} trend="neutral" percentage="" comparisonText="" icon={<FeatherUsers />} />
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
function BillingTenantCard({ row, csrf, submitting }: { row: AdminBillingRow; csrf: string; submitting: boolean }): React.JSX.Element {
|
||||
const { t } = useTranslation();
|
||||
return (
|
||||
<Card>
|
||||
<div className="flex w-full items-start justify-between gap-4 mobile:flex-col">
|
||||
<div className="flex min-w-0 flex-col items-start">
|
||||
<Link to={adminPath(`accounts/${row.tenantId}`, { mode: "host-aware" })} className="text-body-large-0 font-body-large-0 text-text-neutral-primary hover:underline">{row.tenantName}</Link>
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-tertiary">/{row.tenantSlug}</span>
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center justify-end gap-2">
|
||||
<BadgeFeedback farbe={statusTone(row.status)} size="small">{t(row.statusLabelKey)}</BadgeFeedback>
|
||||
<BadgeFeedback farbe={row.planKind === "unassigned" ? "subtle-warning" : "subtle-information"} size="small">{t(row.planKindLabelKey)}</BadgeFeedback>
|
||||
{row.readOnly ? <BadgeFeedback farbe="subtle-negative" size="small">{t("admin.billing.summary.readOnly")}</BadgeFeedback> : null}
|
||||
<BadgeFeedback farbe={row.hasLagoReference ? "subtle-positive" : "subtle-warning"} size="small">{t("admin.billing.providers.lago")}</BadgeFeedback>
|
||||
<BadgeFeedback farbe={row.hasMollieReference ? "subtle-positive" : "subtle-warning"} size="small">{t("admin.billing.providers.mollie")}</BadgeFeedback>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid w-full grid-cols-4 gap-4 mobile:grid-cols-1">
|
||||
{/* `/accounts` renders the same plan as "Business"; this view printed the raw `business` (audit I18N-02). */}
|
||||
<Value label={t("admin.billing.fields.planCode")} value={planCodeLabel(row.planCode)} />
|
||||
<Value label={t("admin.billing.fields.seats")} value={row.seatQuantity} />
|
||||
<Value label={t("admin.billing.fields.readOnlyReason")} value={t(row.readOnlyReasonKey)} />
|
||||
<Value label={t("admin.billing.fields.lastInvoice")} value={row.lastInvoiceExternalId} />
|
||||
</div>
|
||||
|
||||
<Card variant="warning">
|
||||
<span className="text-body-small-regular-150 font-body-small-regular-150 text-text-feedback-warning">{t("admin.billing.overrideNotice")}</span>
|
||||
{/* NumberInput is a fixed 192px-wide component — the seats column must match or the stepper gets overlapped. */}
|
||||
<Form method="post" className="grid w-full grid-cols-[minmax(160px,1fr)_192px_minmax(240px,2fr)_auto] items-end gap-4 mobile:grid-cols-1">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="set-plan-seats" />
|
||||
<input type="hidden" name="tenantId" value={row.tenantId} />
|
||||
<TextInput showLabel label={t("admin.billing.fields.planCode")} fillContainer><TextInput.Input name="planCode" defaultValue={row.planCode ?? ""} placeholder={t("admin.billing.placeholders.planCode")} required /></TextInput>
|
||||
<NumberInput showLabel label={t("admin.billing.fields.seats")}><NumberInput.Input name="seatQuantity" min={1} defaultValue={row.seatQuantity ?? 1} required /></NumberInput>
|
||||
<TextInput showLabel label={t("admin.billing.fields.reason")} fillContainer><TextInput.Input name="reason" placeholder={t("admin.billing.placeholders.reason")} required /></TextInput>
|
||||
<Button type="submit" loading={submitting}>{t("admin.billing.actions.saveOverride")}</Button>
|
||||
</Form>
|
||||
</Card>
|
||||
|
||||
<div className="flex w-full items-center justify-between gap-4 mobile:flex-col mobile:items-start">
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
{(["lago", "mollie"] as const).map((provider) => (
|
||||
<Form key={provider} method="post">
|
||||
<input type="hidden" name="csrf" value={csrf} />
|
||||
<input type="hidden" name="action" value="request-sync" />
|
||||
<input type="hidden" name="tenantId" value={row.tenantId} />
|
||||
<input type="hidden" name="provider" value={provider} />
|
||||
<Button type="submit" variant="secondary" size="small" loading={submitting} icon={<FeatherRefreshCw />}>
|
||||
{t("admin.billing.actions.requestProviderSync", { provider: t(`admin.billing.providers.${provider}`) })}
|
||||
</Button>
|
||||
</Form>
|
||||
))}
|
||||
</div>
|
||||
<div className="flex flex-wrap items-center gap-2">
|
||||
<Link to={adminPath(`audit?tenantId=${row.tenantId}`, { mode: "host-aware" })}><Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>{t("admin.billing.links.audit")}</Button></Link>
|
||||
<Link to={adminPath(`accounts/users?tenantId=${row.tenantId}`, { mode: "host-aware" })}><Button variant="tertiary" size="small" iconRight={<FeatherArrowRight />}>{t("admin.billing.links.users")}</Button></Link>
|
||||
</div>
|
||||
</div>
|
||||
</Card>
|
||||
);
|
||||
}
|
||||
|
||||
function Value({ label, value }: { label: string; value: string | number | null }): React.JSX.Element {
|
||||
return <div className="flex flex-col items-start gap-1"><span className="text-body-extra-small-medium-0 font-body-extra-small-medium-0 uppercase text-text-neutral-tertiary">{label}</span><span className="break-all text-body-small-regular-150 font-body-small-regular-150 text-text-neutral-primary">{value || "-"}</span></div>;
|
||||
}
|
||||
|
||||
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";
|
||||
}
|
||||
Reference in new issue
Block a user