Skip to content
Merged
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
43 changes: 26 additions & 17 deletions resources/js/pages/error.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ type PanelProp = {
};

type Props = {
panel: PanelProp;
panel?: PanelProp;
status: number;
title: string;
message: string;
Expand All @@ -32,24 +32,33 @@ function iconFor(status: number) {
}

export default function ErrorPage({ panel, status, title, message }: Props) {
const __ = create__(panel.translations ?? {});
const __ = create__(panel?.translations ?? {});
const Icon = iconFor(status);
const homeHref = panel?.path ? `/${panel.path}` : '/';

return (
<PanelShell panel={panel}>
<div className="flex min-h-[60vh] flex-col items-center justify-center text-center">
<div className="rounded-full bg-muted p-4">
<Icon className="size-10 text-muted-foreground" />
</div>
<p className="mt-6 font-mono text-sm text-muted-foreground">{status}</p>
<h1 className="mt-2 text-2xl font-semibold tracking-tight">{title}</h1>
<p className="mt-2 max-w-md text-sm text-muted-foreground">{message}</p>
<div className="mt-6 flex items-center gap-2">
<Button variant="ghost" asChild>
<Link href={`/${panel.path}`}>{__('Back to dashboard')}</Link>
</Button>
</div>
const body = (
<div className="flex min-h-[60vh] flex-col items-center justify-center text-center">
<div className="rounded-full bg-muted p-4">
<Icon className="size-10 text-muted-foreground" />
</div>
</PanelShell>
<p className="mt-6 font-mono text-sm text-muted-foreground">{status}</p>
<h1 className="mt-2 text-2xl font-semibold tracking-tight">{title}</h1>
<p className="mt-2 max-w-md text-sm text-muted-foreground">{message}</p>
<div className="mt-6 flex items-center gap-2">
<Button variant="ghost" asChild>
<Link href={homeHref}>{__('Back to dashboard')}</Link>
</Button>
</div>
</div>
);

if (!panel) {
return (
<div className="flex min-h-screen items-center justify-center bg-background p-6">
{body}
</div>
);
}

return <PanelShell panel={panel}>{body}</PanelShell>;
}
Loading