2026-04-13 22:59:38 -04:00
|
|
|
"use client";
|
|
|
|
|
|
2026-04-14 21:26:00 -07:00
|
|
|
import { ExternalLink } from "lucide-react";
|
2026-04-13 22:59:38 -04:00
|
|
|
import Link from "next/link";
|
2026-04-14 21:26:00 -07:00
|
|
|
import { useEffect, useMemo } from "react";
|
|
|
|
|
import { buildIssueUrl } from "@/lib/error-toast";
|
2026-04-13 22:59:38 -04:00
|
|
|
|
|
|
|
|
export default function DashboardError({
|
|
|
|
|
error,
|
|
|
|
|
reset,
|
|
|
|
|
}: {
|
2026-04-14 21:26:00 -07:00
|
|
|
error: globalThis.Error & { digest?: string; code?: string; requestId?: string };
|
2026-04-13 22:59:38 -04:00
|
|
|
reset: () => void;
|
|
|
|
|
}) {
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
import("posthog-js")
|
|
|
|
|
.then(({ default: posthog }) => {
|
|
|
|
|
posthog.captureException(error);
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {});
|
|
|
|
|
}, [error]);
|
|
|
|
|
|
2026-04-14 21:26:00 -07:00
|
|
|
const issueUrl = useMemo(() => buildIssueUrl(error), [error]);
|
|
|
|
|
|
2026-04-13 22:59:38 -04:00
|
|
|
return (
|
|
|
|
|
<div className="flex flex-1 flex-col items-center justify-center gap-4 p-8 text-center">
|
|
|
|
|
<h2 className="text-xl font-semibold">Something went wrong</h2>
|
|
|
|
|
<p className="text-muted-foreground max-w-md">
|
2026-04-14 21:26:00 -07:00
|
|
|
An error occurred in this section. Your dashboard is still available. If this keeps
|
|
|
|
|
happening, please report it so we can fix it.
|
2026-04-13 22:59:38 -04:00
|
|
|
</p>
|
2026-04-14 21:26:00 -07:00
|
|
|
|
|
|
|
|
{(error.digest || error.code || error.requestId) && (
|
|
|
|
|
<div className="rounded-md border bg-muted/50 px-4 py-2 text-xs text-muted-foreground font-mono max-w-md">
|
|
|
|
|
{error.code && <span>Code: {error.code}</span>}
|
|
|
|
|
{error.requestId && <span className="ml-3">ID: {error.requestId}</span>}
|
|
|
|
|
{error.digest && <span className="ml-3">Digest: {error.digest}</span>}
|
|
|
|
|
</div>
|
|
|
|
|
)}
|
|
|
|
|
|
2026-04-13 22:59:38 -04:00
|
|
|
<div className="flex gap-2">
|
|
|
|
|
<button
|
|
|
|
|
type="button"
|
|
|
|
|
onClick={reset}
|
|
|
|
|
className="rounded-md bg-primary px-4 py-2 text-sm font-medium text-primary-foreground hover:bg-primary/90 transition-colors"
|
|
|
|
|
>
|
|
|
|
|
Try again
|
|
|
|
|
</button>
|
|
|
|
|
<Link
|
|
|
|
|
href="/dashboard"
|
|
|
|
|
className="rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground transition-colors"
|
|
|
|
|
>
|
|
|
|
|
Go to dashboard home
|
|
|
|
|
</Link>
|
2026-04-14 21:26:00 -07:00
|
|
|
<a
|
|
|
|
|
href={issueUrl}
|
|
|
|
|
target="_blank"
|
|
|
|
|
rel="noopener noreferrer"
|
|
|
|
|
className="inline-flex items-center gap-1.5 rounded-md border border-input bg-background px-4 py-2 text-sm font-medium hover:bg-accent hover:text-accent-foreground transition-colors"
|
|
|
|
|
>
|
|
|
|
|
<ExternalLink className="h-3.5 w-3.5" />
|
|
|
|
|
Report Issue
|
|
|
|
|
</a>
|
2026-04-13 22:59:38 -04:00
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|