Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 | 1x 10x 10x 10x 1x 2x 2x 1x 2x 1x 2x 1x 2x 1x 2x 2x 1x 2x | import React from "react";
import SubPage from "@/components/page/SubPage/SubPage";
import { MeterBar, MeterTone } from "@/components/detail";
import { useQuery } from "@tanstack/react-query";
import { useApiHandler } from "@/services/useApiHandler";
import { QUERY_KEYS } from "@/services/query_keys";
import { Agent } from "@/objects/Agent";
import { isSystemManaged } from "@/objects/Doc";
import { Model, isSelectableModel } from "@/objects/Model";
import { APP_EMAILS, APP_ROUTES } from "@/routes/const";
import { Link } from "react-router-dom";
import {
BrainCog,
Bot,
Wrench,
FolderKanban,
Library,
Building,
ArrowUpRight,
BarChart3,
Mail,
} from "lucide-react";
import { SettingsTabs } from "./SettingsTabs";
interface UsageBarProps {
icon: React.ElementType;
label: string;
used: number;
limit: number | null;
loading: boolean;
}
const UsageBar: React.FC<UsageBarProps> = ({
icon: Icon,
label,
used,
limit,
loading,
}) => {
const share = limit !== null && limit > 0 ? used / limit : null;
const tone: MeterTone =
share === null
? "muted"
: share >= 0.9
? "danger"
: share >= 0.7
? "warning"
: "ok";
return (
<div className="flex items-center gap-4 py-3 border-b border-gray-100 dark:border-gray-700 last:border-0">
<div className="p-2 rounded-lg bg-gray-100 dark:bg-gray-700 shrink-0">
<Icon className="size-4 text-gray-500 dark:text-gray-400" />
</div>
<div className="flex-1 min-w-0">
<div className="flex justify-between items-baseline mb-1.5">
<span className="text-sm text-gray-700 dark:text-gray-300">{label}</span>
{loading ? (
<span className="w-12 h-4 bg-gray-200 dark:bg-gray-600 rounded animate-pulse" />
) : (
<span className="text-xs text-gray-400 dark:text-gray-500">
{used}
{limit !== null ? ` / ${limit}` : " (unlimited)"}
</span>
)}
</div>
{/* No limit draws a full, faint bar: nothing to run out of. */}
<MeterBar share={share ?? 1} tone={tone} label={label} />
</div>
</div>
);
};
const SettingsSubscription: React.FC = () => {
const { getApiHandler } = useApiHandler();
const { data: agents, isLoading: agentsLoading } = useQuery({
queryKey: [QUERY_KEYS.GET.AGENTS],
queryFn: () => getApiHandler().agent_router.list(),
});
const { data: projects, isLoading: projectsLoading } = useQuery({
queryKey: [QUERY_KEYS.GET.PROJECTS],
queryFn: () => getApiHandler().project_router.list(),
});
const { data: knowledge, isLoading: knowledgeLoading } = useQuery({
queryKey: [QUERY_KEYS.GET.KNOWLEDGE],
queryFn: () => getApiHandler().knowledge_router.list(),
});
const { data: models, isLoading: modelsLoading } = useQuery<Model[] | null>({
queryKey: [QUERY_KEYS.GET.MODELS],
queryFn: () => getApiHandler().model_router.list(),
});
// The models agents can run on. The catalogue also keeps routes this
// deployment has no access to (Amazon Bedrock), which are not resources.
const modelCount = (models ?? []).filter(isSelectableModel).length;
const { data: organisations, isLoading: orgsLoading } = useQuery({
queryKey: [QUERY_KEYS.GET.ORGANISATIONS],
queryFn: () => getApiHandler().organisation_router.list(),
});
return (
<SubPage title="Subscription" links={[<SettingsTabs key="tabs" active="subscription" />]}>
<div className="max-w-xl space-y-6">
{/* Current plan */}
<div className="rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 p-5 shadow-sm">
<div className="flex items-start justify-between mb-4">
<div>
<div className="flex items-center gap-2 mb-1">
<span className="text-lg font-bold text-gray-900 dark:text-gray-100">
Free
</span>
<span className="text-xs font-medium px-2 py-0.5 rounded-full bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400">
Current plan
</span>
</div>
<p className="text-sm text-gray-500 dark:text-gray-400">
For evaluating CHAIN-R on the shared platform, hosted in the UK.
</p>
</div>
</div>
{/* No plan limits or billing exist yet, so this card states none.
Paid plans are agreed directly (docs/business/go-to-market.md). */}
<p className="text-sm text-gray-600 dark:text-gray-300 mb-5">
Team and Enterprise plans run on a dedicated instance. We're
onboarding design partners now.
</p>
<a
href={`mailto:${APP_EMAILS.sales}`}
className="inline-flex items-center gap-2 px-4 py-2 rounded-lg bg-gray-900 dark:bg-white text-white dark:text-gray-900 text-sm font-medium hover:opacity-80 transition-opacity"
>
<Mail className="size-3.5" />
Talk to us
<ArrowUpRight className="size-3.5" />
</a>
</div>
{/* Resource usage */}
<div className="rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 px-5 shadow-sm">
<div className="py-4 border-b border-gray-100 dark:border-gray-700">
<h3 className="text-sm font-semibold text-gray-700 dark:text-gray-300">
Resources
</h3>
</div>
<UsageBar icon={BrainCog} label="Models" used={modelCount} limit={null} loading={modelsLoading} />
<UsageBar icon={Bot} label="Agents" used={(agents ?? []).filter((a: Agent) => !isSystemManaged(a)).length} limit={null} loading={agentsLoading} />
<UsageBar icon={FolderKanban} label="Projects" used={projects?.length ?? 0} limit={null} loading={projectsLoading} />
<UsageBar icon={Library} label="Knowledge Bases" used={knowledge?.length ?? 0} limit={null} loading={knowledgeLoading} />
<UsageBar icon={Building} label="Organisations" used={organisations?.length ?? 0} limit={null} loading={orgsLoading} />
</div>
{/* Tokens and spend */}
<Link
to={APP_ROUTES.USER.stats}
className="flex items-center gap-3 rounded-xl border border-gray-200 dark:border-gray-700 bg-white dark:bg-gray-800 px-5 py-4 shadow-sm hover:border-gray-300 dark:hover:border-gray-600 transition-colors"
>
<BarChart3 className="size-4 text-gray-500 dark:text-gray-400 shrink-0" />
<span className="flex-1 text-sm text-gray-700 dark:text-gray-300">
Tokens, spend and latency by agent, model and project
</span>
<ArrowUpRight className="size-3.5 text-gray-400" />
</Link>
</div>
</SubPage>
);
};
export default SettingsSubscription;
|