Some checks failed
build-images / web (push) Has been cancelled
vision2026-ci / Python SDK resource tests (push) Has been cancelled
build-images / api (push) Has been cancelled
build-images / worker-gpu (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (comfy-workflow-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (effects-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (eventbus-types) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (growth-analytics) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (provider-adapter-kit) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (publishing-connectors) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (render-core) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (shot-template-schema) (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (trends-schema) (push) Has been cancelled
vision2026-ci / Desktop engine crates (test + clippy + fmt) (push) Has been cancelled
codeql / Analyze (javascript-typescript) (push) Has been cancelled
codeql / Analyze (python) (push) Has been cancelled
perf / API hot-path micro-smoke (budgeted) (push) Has been cancelled
perf / Desktop engine crates (release build check) (push) Has been cancelled
vision2026-ci / API phase modules (ruff + pytest) (push) Has been cancelled
vision2026-ci / Alembic upgrade + drift check (push) Has been cancelled
vision2026-ci / Shared packages (TS≡Python golden parity) (caption-engine) (push) Has been cancelled
Paid, hosted product at menivor.com, now retired as a company project. Fresh squashed history of the cleaned working tree (secret-scanned, no .env, no customer data, no outreach logs). Built on MoneyPrinterTurbo (MIT, harry0703) — see NOTICE.
92 lines
2.8 KiB
TypeScript
92 lines
2.8 KiB
TypeScript
"use client";
|
|
|
|
import * as React from "react";
|
|
import { Check, ShieldCheck, X } from "lucide-react";
|
|
import type { Entitlements } from "@/lib/types";
|
|
import {
|
|
Card,
|
|
CardContent,
|
|
CardDescription,
|
|
CardHeader,
|
|
CardTitle,
|
|
} from "@/components/ui/card";
|
|
import { findPlan } from "./plans";
|
|
import { formatEntitlementValue, metricLabel } from "./format";
|
|
|
|
export interface EntitlementsCardProps {
|
|
entitlements: Entitlements | null;
|
|
}
|
|
|
|
/**
|
|
* The workspace's active-plan entitlement bundle (feature → value) as resolved
|
|
* server-side (`GET /me/workspaces/{id}/entitlements`). Booleans render as an
|
|
* included/excluded row; numbers and strings render their formatted value.
|
|
* Tenant-scoped: only the caller's own workspace bundle is ever shown.
|
|
*/
|
|
export function EntitlementsCard({
|
|
entitlements,
|
|
}: Readonly<EntitlementsCardProps>) {
|
|
const entries = React.useMemo(
|
|
() => Object.entries(entitlements?.entitlements ?? {}),
|
|
[entitlements],
|
|
);
|
|
const plan = findPlan(entitlements?.plan_key);
|
|
|
|
return (
|
|
<Card>
|
|
<CardHeader>
|
|
<CardTitle className="flex items-center gap-2">
|
|
<ShieldCheck className="size-5 text-primary" aria-hidden />
|
|
Plan features
|
|
</CardTitle>
|
|
<CardDescription>
|
|
{plan
|
|
? `Included with your ${plan.name} plan.`
|
|
: "Your active plan's included features."}
|
|
</CardDescription>
|
|
</CardHeader>
|
|
<CardContent>
|
|
{entries.length === 0 ? (
|
|
<p className="text-sm text-muted-foreground">
|
|
No entitlements resolved for this workspace.
|
|
</p>
|
|
) : (
|
|
<dl className="grid gap-x-6 gap-y-3 sm:grid-cols-2">
|
|
{entries.map(([key, value]) => (
|
|
<div
|
|
key={key}
|
|
className="flex items-center justify-between gap-3 border-b border-border/60 pb-2 last:border-b-0"
|
|
>
|
|
<dt className="text-sm text-muted-foreground">
|
|
{metricLabel(key)}
|
|
</dt>
|
|
<dd className="text-sm font-medium">
|
|
{typeof value === "boolean" ? (
|
|
<BooleanValue on={value} />
|
|
) : (
|
|
<span className="tabular-nums">
|
|
{formatEntitlementValue(value)}
|
|
</span>
|
|
)}
|
|
</dd>
|
|
</div>
|
|
))}
|
|
</dl>
|
|
)}
|
|
</CardContent>
|
|
</Card>
|
|
);
|
|
}
|
|
|
|
function BooleanValue({ on }: Readonly<{ on: boolean }>) {
|
|
return on ? (
|
|
<span className="flex items-center gap-1 text-success">
|
|
<Check className="size-4" aria-hidden /> Yes
|
|
</span>
|
|
) : (
|
|
<span className="flex items-center gap-1 text-muted-foreground">
|
|
<X className="size-4" aria-hidden /> No
|
|
</span>
|
|
);
|
|
}
|