mirror of
https://github.com/BerriAI/litellm.git
synced 2025-04-24 18:24:20 +00:00
(feat) - ui view spend/budget for your user
This commit is contained in:
parent
44b6c73351
commit
dcc6ddcecf
1 changed files with 54 additions and 0 deletions
54
ui/litellm-dashboard/src/components/view_user_spend.tsx
Normal file
54
ui/litellm-dashboard/src/components/view_user_spend.tsx
Normal file
|
@ -0,0 +1,54 @@
|
|||
"use client";
|
||||
import React, { useEffect } from "react";
|
||||
import { keyDeleteCall } from "./networking";
|
||||
import { StatusOnlineIcon, TrashIcon } from "@heroicons/react/outline";
|
||||
import { DonutChart } from "@tremor/react";
|
||||
import {
|
||||
Badge,
|
||||
Card,
|
||||
Table,
|
||||
Metric,
|
||||
TableBody,
|
||||
TableCell,
|
||||
TableHead,
|
||||
TableHeaderCell,
|
||||
TableRow,
|
||||
Text,
|
||||
Title,
|
||||
Icon,
|
||||
} from "@tremor/react";
|
||||
|
||||
|
||||
// Define the props type
|
||||
interface UserSpendData {
|
||||
spend: number; // Adjust the type accordingly based on your data
|
||||
max_budget?: number | null; // Optional property with a default of null
|
||||
// Add other properties if needed
|
||||
}
|
||||
interface ViewUserSpendProps {
|
||||
userID: string | null;
|
||||
userSpendData: UserSpendData | null; // Use the UserSpendData interface here
|
||||
}
|
||||
const ViewUserSpend: React.FC<ViewUserSpendProps> = ({ userID, userSpendData }) => {
|
||||
console.log("User SpendData:", userSpendData);
|
||||
const spend = userSpendData?.spend;
|
||||
const maxBudget = userSpendData?.max_budget || null;
|
||||
const displayMaxBudget = maxBudget !== null ? `$${maxBudget} limit` : "No limit";
|
||||
const displayText = `$${spend} / ${displayMaxBudget}`;
|
||||
|
||||
return (
|
||||
<>
|
||||
<Card className="mx-auto mb-4">
|
||||
<Metric>
|
||||
${spend}
|
||||
</Metric>
|
||||
<Title>
|
||||
/ {displayMaxBudget}
|
||||
</Title>
|
||||
</Card>
|
||||
</>
|
||||
)
|
||||
}
|
||||
|
||||
export default ViewUserSpend;
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue