Skip to content

Commit ee79198

Browse files
committed
[Dashboard] Fix peak rate date formatting with error handling
1 parent 8910f55 commit ee79198

File tree

1 file changed

+13
-3
lines changed
  • apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/rpc

1 file changed

+13
-3
lines changed

apps/dashboard/src/app/(app)/team/[team_slug]/(team)/~/usage/rpc/page.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,18 @@ export default async function RPCUsage(props: {
6363
Number(totalCounts.rateLimitedCount) +
6464
Number(totalCounts.overageCount);
6565

66+
const peakRateDate = (() => {
67+
if (peakRate.date) {
68+
try {
69+
return format(new Date(`${peakRate.date}Z`), "MMM d, HH:mm");
70+
} catch (e) {
71+
console.error("Error parsing peak rate date", peakRate.date, e);
72+
return null;
73+
}
74+
}
75+
return null;
76+
})();
77+
6678
return (
6779
<div className="container mx-auto space-y-8 py-6">
6880
<div className="flex flex-col gap-2">
@@ -113,9 +125,7 @@ export default async function RPCUsage(props: {
113125
</div>
114126
<p className="mt-1 text-muted-foreground text-xs">
115127
<ClockIcon className="mr-1 inline h-3 w-3" />
116-
{peakRate.date
117-
? format(new Date(`${peakRate.date}Z`), "MMM d, HH:mm")
118-
: "No Requests in last 24 hours"}
128+
{peakRateDate ? peakRateDate : "No Requests in last 24 hours"}
119129
</p>
120130
</CardContent>
121131
</Card>

0 commit comments

Comments
 (0)