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
1 change: 1 addition & 0 deletions messages/en/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@
"usageLogs": "Usage Logs",
"leaderboard": "Leaderboard",
"availability": "Availability",
"myQuota": "My Quota",
"quotasManagement": "Quotas",
"userManagement": "Users",
"providers": "Providers",
Expand Down
1 change: 1 addition & 0 deletions messages/ja/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@
"usageLogs": "使用ログ",
"leaderboard": "ランキング",
"availability": "可用性監視",
"myQuota": "自分のクォータ",
"quotasManagement": "クォータ管理",
"userManagement": "ユーザー",
"providers": "プロバイダー管理",
Expand Down
1 change: 1 addition & 0 deletions messages/ru/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,7 @@
"usageLogs": "Журналы",
"leaderboard": "Лидеры",
"availability": "Доступность",
"myQuota": "Моя квота",
"quotasManagement": "Квоты",
"userManagement": "Пользователи",
"providers": "Управление поставщиками",
Expand Down
1 change: 1 addition & 0 deletions messages/zh-CN/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
"usageLogs": "使用记录",
"leaderboard": "排行榜",
"availability": "可用性监控",
"myQuota": "我的配额",
"quotasManagement": "限额管理",
"providers": "供应商管理",
"documentation": "文档",
Expand Down
1 change: 1 addition & 0 deletions messages/zh-TW/dashboard.json
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,7 @@
"usageLogs": "使用記錄",
"leaderboard": "排行榜",
"availability": "可用性監控",
"myQuota": "我的額度",
"quotasManagement": "額度管理",
"userManagement": "使用者管理",
"providers": "供應商管理",
Expand Down
4 changes: 3 additions & 1 deletion src/app/[locale]/dashboard/_components/dashboard-header.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,9 @@ export function DashboardHeader({ session }: DashboardHeaderProps) {
{ href: "/dashboard/leaderboard", label: t("leaderboard") },
{ href: "/dashboard/availability", label: t("availability"), adminOnly: true },
{ href: "/dashboard/providers", label: t("providers"), adminOnly: true },
{ href: "/dashboard/quotas", label: t("quotasManagement") },
...(isAdmin
? [{ href: "/dashboard/quotas", label: t("quotasManagement") }]
: [{ href: "/dashboard/my-quota", label: t("myQuota") }]),
{ href: "/dashboard/users", label: t("userManagement") },
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The userManagement link should only be visible to admin users. You should add adminOnly: true to this navigation item to prevent non-admin users from seeing a link to a page they cannot access. This would make it consistent with the other admin-only links and the changes you've made for the quotas link.

Suggested change
{ href: "/dashboard/users", label: t("userManagement") },
{ href: "/dashboard/users", label: t("userManagement"), adminOnly: true },

{ href: "/usage-doc", label: t("documentation") },
{ href: "/settings", label: t("systemSettings"), adminOnly: true },
Expand Down
46 changes: 46 additions & 0 deletions src/app/[locale]/dashboard/my-quota/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { AlertCircle } from "lucide-react";
import { getTranslations } from "next-intl/server";
import { getMyQuota } from "@/actions/my-usage";
import { Alert, AlertDescription, AlertTitle } from "@/components/ui/alert";
import { getSystemSettings } from "@/repository/system-config";
import { QuotaCards } from "../../my-usage/_components/quota-cards";

export const dynamic = "force-dynamic";

export default async function MyQuotaPage({ params }: { params: Promise<{ locale: string }> }) {
// Await params to ensure locale is available in the async context
await params;

const [quotaResult, systemSettings, tNav, tCommon] = await Promise.all([
getMyQuota(),
getSystemSettings(),
getTranslations("dashboard.nav"),
getTranslations("common"),
]);

// Handle error state
if (!quotaResult.ok) {
return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h3 className="text-lg font-medium">{tNav("myQuota")}</h3>
</div>
<Alert variant="destructive">
<AlertCircle className="h-4 w-4" />
<AlertTitle>{tCommon("error")}</AlertTitle>
<AlertDescription>{quotaResult.error}</AlertDescription>
</Alert>
</div>
);
}

return (
<div className="space-y-4">
<div className="flex items-center justify-between">
<h3 className="text-lg font-medium">{tNav("myQuota")}</h3>
</div>

<QuotaCards quota={quotaResult.data} currencyCode={systemSettings.currencyDisplay} />
</div>
);
}
2 changes: 1 addition & 1 deletion src/app/[locale]/dashboard/quotas/keys/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default async function KeysQuotaPage({ params }: { params: Promise<{ loca

// 权限检查:仅 admin 用户可访问
if (!session || session.user.role !== "admin") {
redirect({ href: session ? "/dashboard" : "/login", locale });
redirect({ href: session ? "/dashboard/my-quota" : "/login", locale });
}

redirect({ href: "/dashboard/quotas/users", locale });
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/dashboard/quotas/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default async function QuotasPage({ params }: { params: Promise<{ locale:
}

if (session.user.role !== "admin") {
return redirect({ href: "/my-usage", locale });
return redirect({ href: "/dashboard/my-quota", locale });
}

return redirect({ href: "/dashboard/quotas/users", locale });
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/dashboard/quotas/providers/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export default async function ProvidersQuotaPage({

// 权限检查:仅 admin 用户可访问
if (!session || session.user.role !== "admin") {
redirect({ href: session ? "/dashboard" : "/login", locale });
redirect({ href: session ? "/dashboard/my-quota" : "/login", locale });
}

const t = await getTranslations("quota.providers");
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/dashboard/quotas/users/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export default async function UsersQuotaPage({ params }: { params: Promise<{ loc

// 权限检查:仅 admin 用户可访问
if (!session || session.user.role !== "admin") {
return redirect({ href: session ? "/dashboard" : "/login", locale });
return redirect({ href: session ? "/dashboard/my-quota" : "/login", locale });
}

const t = await getTranslations("quota.users");
Expand Down
Loading