diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerBudgetSummary.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerBudgetSummary.tsx
index 69c98d614ec..6384f14d5ab 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerBudgetSummary.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerBudgetSummary.tsx
@@ -1,6 +1,6 @@
import { useTranslation } from "react-i18next";
import type { CustomerUsageEntity } from "./customerUsageApi";
-import CustomerBudgetSpend, { CustomerBudgetWindow } from "./CustomerBudgetSpend";
+import { CustomerBudgetWindow } from "./CustomerBudgetSpend";
import { CUSTOMER_BUDGET_LABELS, customerBudgetPeriod, customerBudgetUsage } from "./customerBudgetUsage";
export default function CustomerBudgetSummary({
@@ -35,10 +35,10 @@ export default function CustomerBudgetSummary({
);
})}
- {budgets.length === 0 && (
-
+ {budgets.length === 0 &&
{t("customerPortal.analytics.noBudget")}
}
+ {budgets.length > 0 && (
+ {t("customerPortal.analytics.budgetUsageHint")}
)}
- {t("customerPortal.analytics.budgetUsageHint")}
);
}
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyManager.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyManager.tsx
index ad75a9b62f5..f3d33f82db1 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyManager.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyManager.tsx
@@ -9,8 +9,7 @@ import { ErrorState } from "@/components/shared/ErrorState";
import { Button } from "@/components/ui/button";
import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from "@/components/ui/table";
import { extractProxyErrorMessage } from "@/lib/http/client";
-import { uiHref } from "@/utils/uiHref";
-import CustomerHierarchyNavigation, { customerHierarchyHref } from "./CustomerHierarchyNavigation";
+import CustomerHierarchyNavigation, { useCustomerHierarchyLinks } from "./CustomerHierarchyNavigation";
import CustomerHierarchySettings from "./CustomerHierarchySettings";
import CustomerBudgetGroups from "./CustomerBudgetGroups";
import CustomerBudgetSummary from "./CustomerBudgetSummary";
@@ -39,6 +38,7 @@ const DESCRIPTION_KEYS = {
function HierarchyHeader({ hierarchy, selected }: Pick) {
const { t } = useTranslation();
+ const { customerHierarchyHref, customersHref } = useCustomerHierarchyLinks();
const entity = selected.entity;
const team = selected.team;
const label = customerEntityLabel(entity);
@@ -70,7 +70,7 @@ function HierarchyHeader({ hierarchy, selected }: Pick
-
+
{t("customerPortal.entities.organizations")}
@@ -147,6 +147,7 @@ function hierarchyRows({ hierarchy, selected, scope }: ScopeProps) {
}
function HierarchyCreateAction({ hierarchy, selected, scope }: ScopeProps) {
+ const { customerHierarchyHref } = useCustomerHierarchyLinks();
const { t } = useTranslation();
const [open, setOpen] = useState(false);
if (hierarchy.childTab === "members" && selected.team === null)
@@ -178,6 +179,7 @@ function HierarchyCreateAction({ hierarchy, selected, scope }: ScopeProps) {
}
function HierarchyChildTable(props: ScopeProps) {
+ const { customerHierarchyHref } = useCustomerHierarchyLinks();
const { t } = useTranslation();
const { hierarchy } = props;
const { children, childTab, page } = hierarchy;
@@ -302,6 +304,7 @@ function HierarchyChildTable(props: ScopeProps) {
}
export default function CustomerHierarchyManager() {
+ const { customersHref } = useCustomerHierarchyLinks();
const { t } = useTranslation();
const router = useRouter();
const hierarchy = useCustomerHierarchy();
@@ -319,7 +322,7 @@ export default function CustomerHierarchyManager() {
@@ -349,7 +352,7 @@ export default function CustomerHierarchyManager() {
hierarchy.refresh();
if (selected.member && selected.team) hierarchy.openTeam(selected.team.customer_team_id);
else if (selected.team) hierarchy.openOrganization();
- else router.push(uiHref("customers"));
+ else router.push(customersHref);
};
return (
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyNavigation.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyNavigation.tsx
index 44e164a0975..d89461cc429 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyNavigation.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerHierarchyNavigation.tsx
@@ -1,7 +1,9 @@
import { useTranslation } from "react-i18next";
+import { createSerializer, parseAsString, useQueryStates, type inferParserType } from "nuqs";
import { cn } from "@/lib/cva.config";
import { uiHref } from "@/utils/uiHref";
import type { CustomerUsageScope } from "./customerUsageApi";
+import { customerUsageDateParsers } from "./customerUsageRange";
type CustomerHierarchyView = "usage" | "teams" | "members" | "budget_groups" | "settings";
const LABELS = {
@@ -12,11 +14,30 @@ const LABELS = {
settings: "customerPortal.hierarchy.settings",
} as const;
-export function customerHierarchyHref(page: "usage" | "manage", scope: CustomerUsageScope): string {
- const query = new URLSearchParams({ org: scope.org });
- if (scope.team) query.set("team", scope.team);
- if (scope.member) query.set("member", scope.member);
- return `${uiHref(`customers/${page}`)}?${query}`;
+const hierarchyParsers = {
+ org: parseAsString,
+ team: parseAsString,
+ member: parseAsString,
+ ...customerUsageDateParsers,
+};
+const hierarchyHref = createSerializer(hierarchyParsers);
+const listHref = createSerializer(customerUsageDateParsers);
+
+export function customerHierarchyHref(
+ page: "usage" | "manage",
+ scope: CustomerUsageScope,
+ dates: Partial> = {},
+): string {
+ return hierarchyHref(uiHref(`customers/${page}`), { ...scope, ...dates });
+}
+
+export function useCustomerHierarchyLinks() {
+ const [dates] = useQueryStates(customerUsageDateParsers);
+ return {
+ customerHierarchyHref: (page: "usage" | "manage", scope: CustomerUsageScope) =>
+ customerHierarchyHref(page, scope, dates),
+ customersHref: listHref(uiHref("customers"), dates),
+ };
}
export default function CustomerHierarchyNavigation({
@@ -27,6 +48,7 @@ export default function CustomerHierarchyNavigation({
active: CustomerHierarchyView;
}) {
const { t } = useTranslation();
+ const { customerHierarchyHref } = useCustomerHierarchyLinks();
let pages: readonly CustomerHierarchyView[] = ["usage", "teams", "members", "budget_groups", "settings"];
if (scope.team) pages = ["usage", "members", "settings"];
if (scope.member) pages = ["usage", "settings"];
diff --git a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerUsageHeader.tsx b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerUsageHeader.tsx
index 51836279f13..7bc73914e9e 100644
--- a/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerUsageHeader.tsx
+++ b/litellm/ui/litellm-dashboard/src/app/(dashboard)/customers/_components/CustomerUsageHeader.tsx
@@ -3,7 +3,8 @@ import { ChevronRight } from "lucide-react";
import { useTranslation } from "react-i18next";
import AdvancedDatePicker from "@/components/shared/advanced_date_picker";
import type { DateRangePickerValue } from "@/components/shared/date_picker_types";
-import { uiHref } from "@/utils/uiHref";
+import { useCustomerHierarchyLinks } from "./CustomerHierarchyNavigation";
+import { customerUsagePresets, CUSTOMER_USAGE_MAX_RANGE_DAYS } from "./customerUsageRange";
import type { CustomerHierarchyUsage, CustomerUsageScope } from "./customerUsageApi";
interface CustomerUsageHeaderProps {
@@ -29,12 +30,13 @@ function CustomerUsageBreadcrumbs({
onTeamClick,
}: Pick) {
const { t } = useTranslation();
+ const { customersHref } = useCustomerHierarchyLinks();
return (