i18n observability hub: analytics pages and log tables.
Translate analytics overview/activity/economy plus peak-hours/revenue charts, and audit/chat/commands/trades DataTables (en/nl/it). Includes prior events/polls detail i18n. Co-authored-by: Cursor <[email protected]>
This commit is contained in:
1 parent
a25008deb5
commit
bcbdca841b
13 files changed
+576
-211
No files matched your search
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslations } from "next-intl";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
import {
|
||||
Tooltip,
|
||||
@@ -14,7 +15,7 @@ interface PeakHoursData {
|
||||
max: number;
|
||||
}
|
||||
|
||||
const DAYS = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
|
||||
const DAY_KEYS = ["mon", "tue", "wed", "thu", "fri", "sat", "sun"] as const;
|
||||
const HOURS = Array.from({ length: 24 }, (_, i) => i);
|
||||
|
||||
function getColor(value: number, max: number) {
|
||||
@@ -28,13 +29,14 @@ function getColor(value: number, max: number) {
|
||||
}
|
||||
|
||||
export function PeakHoursHeatmap({ data }: { data: PeakHoursData }) {
|
||||
const t = useTranslations("pages.admin.analytics.peakHours");
|
||||
const days = DAY_KEYS.map((key) => t(`days.${key}`));
|
||||
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium">Peak Hours</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">
|
||||
User activity by day & hour (last 7 days)
|
||||
</p>
|
||||
<CardTitle className="text-sm font-medium">{t("title")}</CardTitle>
|
||||
<p className="text-xs text-muted-foreground">{t("description")}</p>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="overflow-x-auto">
|
||||
@@ -51,8 +53,8 @@ export function PeakHoursHeatmap({ data }: { data: PeakHoursData }) {
|
||||
))}
|
||||
</div>
|
||||
{/* Rows */}
|
||||
{DAYS.map((day, dayIdx) => (
|
||||
<div key={day} className="flex items-center gap-px mb-px">
|
||||
{days.map((day, dayIdx) => (
|
||||
<div key={DAY_KEYS[dayIdx]} className="flex items-center gap-px mb-px">
|
||||
<span className="w-10 text-xs text-muted-foreground text-right pr-2 shrink-0">
|
||||
{day}
|
||||
</span>
|
||||
@@ -67,7 +69,7 @@ export function PeakHoursHeatmap({ data }: { data: PeakHoursData }) {
|
||||
/>
|
||||
</TooltipTrigger>
|
||||
<TooltipContent side="top" className="text-xs">
|
||||
{day} {hour}:00 — {count} users
|
||||
{t("tooltip", { day, hour, count })}
|
||||
</TooltipContent>
|
||||
</Tooltip>
|
||||
);
|
||||
@@ -77,13 +79,17 @@ export function PeakHoursHeatmap({ data }: { data: PeakHoursData }) {
|
||||
))}
|
||||
{/* Legend */}
|
||||
<div className="flex items-center gap-2 mt-3 ml-10">
|
||||
<span className="text-[10px] text-muted-foreground">Less</span>
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
{t("less")}
|
||||
</span>
|
||||
<div className="h-3 w-3 rounded-sm bg-muted" />
|
||||
<div className="h-3 w-3 rounded-sm bg-[var(--admin-success)]/20" />
|
||||
<div className="h-3 w-3 rounded-sm bg-[var(--admin-success)]/55" />
|
||||
<div className="h-3 w-3 rounded-sm bg-[var(--admin-success)] dark:bg-[var(--admin-success)]" />
|
||||
<div className="h-3 w-3 rounded-sm bg-[var(--admin-success-strong,var(--admin-success))]" />
|
||||
<span className="text-[10px] text-muted-foreground">More</span>
|
||||
<span className="text-[10px] text-muted-foreground">
|
||||
{t("more")}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"use client";
|
||||
|
||||
import { useTranslations } from "next-intl";
|
||||
import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card";
|
||||
|
||||
interface RevenueDataPoint {
|
||||
@@ -9,6 +10,7 @@ interface RevenueDataPoint {
|
||||
}
|
||||
|
||||
export function RevenueChart({ data }: { data: RevenueDataPoint[] }) {
|
||||
const t = useTranslations("pages.admin.analytics.economy");
|
||||
const max = Math.max(
|
||||
1,
|
||||
...data.flatMap((point) => [point.credits, point.points]),
|
||||
@@ -16,7 +18,9 @@ export function RevenueChart({ data }: { data: RevenueDataPoint[] }) {
|
||||
return (
|
||||
<Card>
|
||||
<CardHeader className="pb-2">
|
||||
<CardTitle className="text-sm font-medium">Catalog Spending</CardTitle>
|
||||
<CardTitle className="text-sm font-medium">
|
||||
{t("catalogSpendingTitle")}
|
||||
</CardTitle>
|
||||
</CardHeader>
|
||||
<CardContent>
|
||||
<div className="space-y-3">
|
||||
@@ -32,14 +36,14 @@ export function RevenueChart({ data }: { data: RevenueDataPoint[] }) {
|
||||
style={{
|
||||
width: `${Math.max(2, (point.credits / max) * 100)}%`,
|
||||
}}
|
||||
title={`${point.credits} credits`}
|
||||
title={t("creditsTooltip", { count: point.credits })}
|
||||
/>
|
||||
<div
|
||||
className="h-2 rounded bg-[var(--admin-accent)]"
|
||||
style={{
|
||||
width: `${Math.max(2, (point.points / max) * 100)}%`,
|
||||
}}
|
||||
title={`${point.points} points`}
|
||||
title={t("pointsTooltip", { count: point.points })}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Reference in new issue
Block a user