mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
8478b1f28f
Add dedicated 403 pages for the app and admin area, enable Next.js forbidden handling, and improve admin loading, navigation, and error-boundary experiences.
101 lines
5.9 KiB
TypeScript
101 lines
5.9 KiB
TypeScript
import { Metadata } from 'next';
|
|
import Link from 'next/link';
|
|
import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card';
|
|
import { Button } from '@/components/ui/button';
|
|
import { LayoutDashboard, Home, ShieldAlert, KeyRound, ArrowLeft } from 'lucide-react';
|
|
|
|
export const metadata: Metadata = {
|
|
title: 'Access Restricted | Admin',
|
|
description: 'You do not have permission to access this administrative page.',
|
|
};
|
|
|
|
export default function AdminForbiddenPage() {
|
|
return (
|
|
<div className="flex flex-col w-full max-w-4xl mx-auto py-2 sm:py-6">
|
|
<Card className="border-zinc-200/90 dark:border-zinc-800/90 shadow-sm overflow-hidden">
|
|
<CardHeader className="flex flex-col sm:flex-row items-start sm:items-center gap-4 pb-4 border-b border-zinc-100 dark:border-zinc-800/80">
|
|
{/* Security Icon Badge */}
|
|
<div className="w-12 h-12 rounded-xl bg-rose-500/10 text-rose-600 border border-rose-500/20 dark:bg-rose-500/20 dark:text-rose-400 flex items-center justify-center shrink-0">
|
|
<i className="ti ti-shield-lock text-2xl" />
|
|
</div>
|
|
|
|
<div className="space-y-1 flex-1">
|
|
<div className="flex items-center gap-2 flex-wrap">
|
|
<CardTitle className="text-xl font-bold tracking-tight text-zinc-900 dark:text-zinc-50">
|
|
Access Restricted
|
|
</CardTitle>
|
|
<span className="inline-flex items-center px-2 py-0.5 rounded text-[11px] font-mono font-medium bg-rose-500/10 text-rose-600 border border-rose-500/20 dark:bg-rose-500/20 dark:text-rose-400">
|
|
HTTP 403
|
|
</span>
|
|
</div>
|
|
<CardDescription className="text-zinc-600 dark:text-zinc-400 text-sm">
|
|
Your account does not have sufficient role permissions to view or manage this administrative resource.
|
|
</CardDescription>
|
|
</div>
|
|
</CardHeader>
|
|
|
|
<CardContent className="space-y-6 pt-6">
|
|
{/* Explanation Box */}
|
|
<div className="p-4 rounded-lg bg-zinc-50 dark:bg-zinc-900/60 border border-zinc-200/80 dark:border-zinc-800 space-y-3">
|
|
<div className="flex items-center gap-2 text-zinc-800 dark:text-zinc-200 text-sm font-semibold">
|
|
<ShieldAlert size={16} className="text-rose-500 shrink-0" />
|
|
<span>Why am I seeing this page?</span>
|
|
</div>
|
|
|
|
<p className="text-xs sm:text-sm text-zinc-600 dark:text-zinc-400 leading-relaxed">
|
|
Access to this section is protected by Role-Based Access Control (RBAC). Your assigned user role has not been granted the necessary permissions for this menu action or route.
|
|
</p>
|
|
|
|
<div className="pt-2 flex flex-wrap gap-2 text-xs">
|
|
<div className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 text-zinc-700 dark:text-zinc-300 font-mono text-[11px]">
|
|
<KeyRound size={12} className="text-his" />
|
|
<span>Policy: Role Permission Required</span>
|
|
</div>
|
|
<div className="inline-flex items-center gap-1.5 px-2.5 py-1 rounded-md bg-white dark:bg-zinc-950 border border-zinc-200 dark:border-zinc-800 text-zinc-700 dark:text-zinc-300 font-mono text-[11px]">
|
|
<span>Area: Admin Panel</span>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
{/* How to Resolve */}
|
|
<div className="space-y-2 text-xs text-muted-foreground leading-relaxed">
|
|
<p className="font-medium text-zinc-700 dark:text-zinc-300">
|
|
Need access to this resource?
|
|
</p>
|
|
<p>
|
|
Please contact HATs system administrator, Manager or Team Leader to request the relevant permission assignment for your account role.
|
|
</p>
|
|
</div>
|
|
|
|
{/* Action Buttons */}
|
|
<div className="flex flex-col sm:flex-row items-stretch sm:items-center justify-between gap-3 pt-2">
|
|
<div className="flex items-center gap-2.5 flex-wrap">
|
|
<Link href="/admin">
|
|
<Button className="bg-his hover:bg-his/90 text-white font-medium inline-flex items-center gap-2 shadow-sm">
|
|
<LayoutDashboard size={15} />
|
|
Back to Admin Dashboard
|
|
</Button>
|
|
</Link>
|
|
|
|
<Link href="/">
|
|
<Button variant="outline" className="inline-flex items-center gap-2 font-medium">
|
|
<Home size={15} />
|
|
Homepage
|
|
</Button>
|
|
</Link>
|
|
</div>
|
|
|
|
<Link href="/auth" className="self-center sm:self-auto">
|
|
<Button variant="ghost" size="sm" className="text-xs text-muted-foreground inline-flex items-center gap-1.5">
|
|
<ArrowLeft size={13} />
|
|
Switch Account
|
|
</Button>
|
|
</Link>
|
|
</div>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|
|
|