feat: add the active users and median spend cards (#32340)

## Description

Adds the **Active users** and **Median spend** cards to the AI spend
Overview tab, from the user count and median spend the overview endpoint
already returns.

## Changes

- Render both cards with `StatCard`, side by side below **Total spend**.
- Add a story for an organization with no spend in the period.

Related to AIGOV-732

> [!NOTE]
> Generated by Coder Agents on behalf of @ssncferreira.
This commit is contained in:
Susana Ferreira authored and GitHub committed 2026-11-20 17:15:27 +00:00
1 parent dac4d49370
commit c4ba26df76
2 files changed
+30

No files matched your search

@@ -47,6 +47,17 @@ export const OverviewLoading: Story = {
},
};
export const NoSpend: Story = {
args: {
overview: {
...MockOrganizationAISpendOverview,
count: 0,
totals: { spend_micros: 0, median_spend_micros: 0 },
},
unpricedModels: [],
},
};
export const SingleOrganization: Story = {
args: { organizations: [MockOrganization] },
};
@@ -1,3 +1,4 @@
import { CoinsIcon, UsersIcon } from "lucide-react";
import {
MaxAISpendPeriodDays,
type OrganizationAISpendOverview,
@@ -5,6 +6,8 @@ import {
} from "#/api/typesGenerated";
import { ErrorAlert } from "#/components/Alert/ErrorAlert";
import { DateRangePicker } from "#/components/DateRangePicker/DateRangePicker";
import { formatCostMicros } from "#/utils/currency";
import { StatCard } from "./StatCard";
import {
fromPickerValue,
type SpendDays,
@@ -52,6 +55,22 @@ export const OverviewTab: React.FC<OverviewTabProps> = ({
unpricedModels={unpricedModels}
isUnpricedModelsLoading={isUnpricedModelsLoading}
/>
<div className="grid gap-6 sm:grid-cols-2">
<StatCard
icon={UsersIcon}
label="Active users"
value={overview?.count.toLocaleString("en-US")}
/>
<StatCard
icon={CoinsIcon}
label="Median spend"
value={
overview === undefined
? undefined
: formatCostMicros(overview.totals.median_spend_micros)
}
/>
</div>
</div>
</div>
)}