The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
Add UsageDatePicker component for usage dashboards
Cole McIntosh52e51ead0365
diff --git a/ui/litellm-dashboard/src/components/shared/usage_date_picker.tsx b/ui/litellm-dashboard/src/components/shared/usage_date_picker.tsxnew file mode 100644index 00000000000..039cee4fc06--- /dev/null+++ b/ui/litellm-dashboard/src/components/shared/usage_date_picker.tsx@@ -0,0 +1,66 @@+import React from "react";+import { DateRangePicker, DateRangePickerValue, Text } from "@tremor/react";++interface UsageDatePickerProps {+ value: DateRangePickerValue;+ onValueChange: (value: DateRangePickerValue) => void;+ label?: string;+ className?: string;+}++/**+ * Reusable date picker component for usage dashboards.+ * Handles proper time boundaries for date ranges, especially "Today" selections.+ */+const UsageDatePicker: React.FC<UsageDatePickerProps> = ({+ value,+ onValueChange,+ label = "Select Time Range",+ className = ""+}) => {+ const handleDateChange = (newValue: DateRangePickerValue) => {+ // Handle the case where "Today" or same-day selection is made+ if (newValue.from && newValue.to) {+ const adjustedValue = { ...newValue };++ // Create new Date objects to avoid mutating the original dates+ const adjustedStartTime = new Date(newValue.from);+ const adjustedEndTime = new Date(newValue.to);++ // Check if it's the same day (Today selection)+ const isSameDay =+ adjustedStartTime.toDateString() === adjustedEndTime.toDateString();++ if (isSameDay) {+ // For same-day selections (like "Today"), set proper time boundaries+ adjustedStartTime.setHours(0, 0, 0, 0); // Start of day+ adjustedEndTime.setHours(23, 59, 59, 999); // End of day+ } else {+ // For multi-day ranges, set start to beginning of first day and end to end of last day+ adjustedStartTime.setHours(0, 0, 0, 0);+ adjustedEndTime.setHours(23, 59, 59, 999);+ }++ adjustedValue.from = adjustedStartTime;+ adjustedValue.to = adjustedEndTime;++ onValueChange(adjustedValue);+ } else {+ // If either date is missing, pass through as-is+ onValueChange(newValue);+ }+ };++ return (+ <div className={className}>+ {label && <Text className="mb-2">{label}</Text>}+ <DateRangePicker+ enableSelect={true}+ value={value}+ onValueChange={handleDateChange}+ />+ </div>+ );+};++export default UsageDatePicker;\ No newline at end of file