Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions messages/en/myUsage.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"keyStats": "Key",
"userStats": "User",
"noData": "No data for selected period",
"breakdownPrevPage": "Previous page",
"breakdownNextPage": "Next page",
"breakdownPageIndicator": "{current} / {total}",
"unknownModel": "Unknown",
"modal": {
"requests": "Requests",
Expand Down
3 changes: 3 additions & 0 deletions messages/ja/myUsage.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"keyStats": "キー",
"userStats": "ユーザー",
"noData": "選択期間のデータがありません",
"breakdownPrevPage": "前のページ",
"breakdownNextPage": "次のページ",
"breakdownPageIndicator": "{current} / {total}",
"unknownModel": "不明",
"modal": {
"requests": "リクエスト",
Expand Down
3 changes: 3 additions & 0 deletions messages/ru/myUsage.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"keyStats": "Ключ",
"userStats": "Пользователь",
"noData": "Нет данных за выбранный период",
"breakdownPrevPage": "Предыдущая страница",
"breakdownNextPage": "Следующая страница",
"breakdownPageIndicator": "{current} / {total}",
"unknownModel": "Неизвестно",
"modal": {
"requests": "Запросов",
Expand Down
3 changes: 3 additions & 0 deletions messages/zh-CN/myUsage.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"keyStats": "密钥",
"userStats": "用户",
"noData": "所选时段无数据",
"breakdownPrevPage": "上一页",
"breakdownNextPage": "下一页",
"breakdownPageIndicator": "{current} / {total}",
"unknownModel": "未知",
"modal": {
"requests": "请求",
Expand Down
3 changes: 3 additions & 0 deletions messages/zh-TW/myUsage.json
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,9 @@
"keyStats": "金鑰",
"userStats": "使用者",
"noData": "所選時段無資料",
"breakdownPrevPage": "上一頁",
"breakdownNextPage": "下一頁",
"breakdownPageIndicator": "{current} / {total}",
"unknownModel": "不明",
"modal": {
"requests": "請求",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,26 +251,29 @@ function UsageLogsViewContent({
};
}, []);

const statsFilters = {
userId: filters.userId,
keyId: filters.keyId,
providerId: filters.providerId,
sessionId: filters.sessionId,
startTime: filters.startTime,
endTime: filters.endTime,
statusCode: filters.statusCode,
excludeStatusCode200: filters.excludeStatusCode200,
model: filters.model,
endpoint: filters.endpoint,
minRetryCount: filters.minRetryCount,
};
Comment on lines +254 to +266
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

medium

For better maintainability, you can create statsFilters by using object destructuring to exclude the page property from filters. This avoids having to manually list every property and prevents potential bugs if new filters are added in the future.

const { page, ...statsFilters } = filters;


const hasStatsFilters = Object.values(statsFilters).some((v) => v !== undefined && v !== false);

return (
<>
<div className="space-y-4">
{/* Stats Summary - Collapsible */}
<UsageLogsStatsPanel
filters={{
userId: filters.userId,
keyId: filters.keyId,
providerId: filters.providerId,
sessionId: filters.sessionId,
startTime: filters.startTime,
endTime: filters.endTime,
statusCode: filters.statusCode,
excludeStatusCode200: filters.excludeStatusCode200,
model: filters.model,
endpoint: filters.endpoint,
minRetryCount: filters.minRetryCount,
}}
currencyCode={resolvedCurrencyCode}
/>
{hasStatsFilters && (
<UsageLogsStatsPanel filters={statsFilters} currencyCode={resolvedCurrencyCode} />
)}

{/* Filter Criteria */}
<Card className="border-border/50">
Expand Down
262 changes: 0 additions & 262 deletions src/app/[locale]/dashboard/logs/_components/usage-logs-view.tsx

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
"use client";

import { AlertTriangle, ChevronDown, Infinity, PieChart } from "lucide-react";
import { AlertTriangle, ChevronDown, Infinity as InfinityIcon, PieChart } from "lucide-react";
import { useTranslations } from "next-intl";
import { useState } from "react";
import type { MyUsageQuota } from "@/actions/my-usage";
Expand Down Expand Up @@ -94,7 +94,7 @@ export function CollapsibleQuotaCard({
<div className="flex items-center gap-1.5">
<span className="text-muted-foreground">{t("daily")}:</span>
{dailyPct === null ? (
<Infinity className="h-4 w-4 text-muted-foreground" />
<InfinityIcon className="h-4 w-4 text-muted-foreground" />
) : (
<>
<span className={cn("font-semibold", getPercentColor(dailyPct))}>
Expand All @@ -108,7 +108,7 @@ export function CollapsibleQuotaCard({
<div className="flex items-center gap-1.5">
<span className="text-muted-foreground">{t("monthly")}:</span>
{monthlyPct === null ? (
<Infinity className="h-4 w-4 text-muted-foreground" />
<InfinityIcon className="h-4 w-4 text-muted-foreground" />
) : (
<>
<span className={cn("font-semibold", getPercentColor(monthlyPct))}>
Expand All @@ -122,7 +122,7 @@ export function CollapsibleQuotaCard({
<div className="flex items-center gap-1.5">
<span className="text-muted-foreground">{t("total")}:</span>
{totalPct === null ? (
<Infinity className="h-4 w-4 text-muted-foreground" />
<InfinityIcon className="h-4 w-4 text-muted-foreground" />
) : (
<>
<span className={cn("font-semibold", getPercentColor(totalPct))}>
Expand Down
Loading
Loading