diff --git a/app/(protected)/dashboard/scrape/daily-chart.tsx b/app/(protected)/dashboard/scrape/daily-chart.tsx index 9aa1bbd..2f85bc9 100644 --- a/app/(protected)/dashboard/scrape/daily-chart.tsx +++ b/app/(protected)/dashboard/scrape/daily-chart.tsx @@ -6,7 +6,7 @@ import { ScrapeMeta } from "@prisma/client"; import { useTranslations } from "next-intl"; import { Area, AreaChart, CartesianGrid, XAxis, YAxis } from "recharts"; -import { isLink, nFormatter, removeUrlSuffix, timeAgo } from "@/lib/utils"; +import { isLink, nFormatter, removeUrlSuffix } from "@/lib/utils"; import { Card, CardContent, @@ -19,6 +19,7 @@ import { ChartTooltip, ChartTooltipContent, } from "@/components/ui/chart"; +import { TimeAgoIntl } from "@/components/shared/time-ago"; const chartConfig = { request: { @@ -102,23 +103,21 @@ export function DailyPVUVChart({ data }: { data: ScrapeMeta[] }) { (a, b) => new Date(a.updatedAt).getTime() - new Date(b.updatedAt).getTime(), ); const latestEntry = sort_data[sort_data.length - 1]; - const latestDate = timeAgo(latestEntry.updatedAt); const latestFrom = latestEntry.type; const t = useTranslations("Components"); + const lastRequestInfo = t.rich("last-request-info", { + location: latestFrom, + timeAgo: () => , + }); + return (
{t("Total Requests of APIs in Last 30 Days")} - - {t("Last request from {latestFrom} api about {latestDate}", { - latestFrom, - latestDate, - })} - . - + {lastRequestInfo}
{["request", "ip"].map((key) => { diff --git a/app/(protected)/dashboard/urls/meta-chart.tsx b/app/(protected)/dashboard/urls/meta-chart.tsx index fbd99be..8c38a57 100644 --- a/app/(protected)/dashboard/urls/meta-chart.tsx +++ b/app/(protected)/dashboard/urls/meta-chart.tsx @@ -20,7 +20,7 @@ import { getRegionName, } from "@/lib/contries"; import { DATE_DIMENSION_ENUMS } from "@/lib/enums"; -import { isLink, removeUrlSuffix, timeAgo } from "@/lib/utils"; +import { isLink, removeUrlSuffix } from "@/lib/utils"; import { useElementSize } from "@/hooks/use-element-size"; import { Button } from "@/components/ui/button"; import { @@ -45,6 +45,7 @@ import { } from "@/components/ui/select"; import { Tabs, TabsContent, TabsList, TabsTrigger } from "@/components/ui/tabs"; import { Icons } from "@/components/shared/icons"; +import { TimeAgoIntl } from "@/components/shared/time-ago"; const chartConfig = { pv: { @@ -187,7 +188,6 @@ export function DailyPVUVChart({ const dataTotal = calculateUVAndPV(data); const latestEntry = data[data.length - 1]; - const latestDate = timeAgo(latestEntry.updatedAt); const latestFrom = [ latestEntry.city ? decodeURIComponent(latestEntry.city) : "", latestEntry.country ? `(${getCountryName(latestEntry.country)})` : "", @@ -241,18 +241,17 @@ export function DailyPVUVChart({ const regionStats = generateStatsList(data, "region"); const isBotStats = generateStatsList(data, "isBot"); + const lastVisitorInfo = t.rich("last-visitor-info", { + location: latestFrom, + timeAgo: () => , + }); + return (
{t("Link Analytics")} - - {t("Last visitor from {latestFrom} about {latestDate}", { - latestFrom, - latestDate, - })} - . - + {lastVisitorInfo}