Files
hats-app/app/forbidden/page.tsx
T
Ichsan Kurniawan e67f671983 Enforce assignment permissions and show active milestones
Gate assignment creation and editing by the relevant permissions, show ongoing milestones on the timeline, and restrict the forbidden-page admin link to authorized users. Also use the shared RBAC role type and tighten sidebar active-state matching.
2026-11-10 11:27:05 +07:00

81 lines
4.1 KiB
TypeScript

import { Metadata } from 'next';
import Link from 'next/link';
import { Button } from '@/components/ui/button';
import { Home, LayoutDashboard, ArrowLeft, Lock } from 'lucide-react';
import { getCacheServerSession } from '@/lib/get-access-data';
export const metadata: Metadata = {
title: '403 Forbidden | H.A.T.s',
description: 'You do not have permission to access this page.',
};
export default async function ForbiddenPage() {
const session = await getCacheServerSession()
return (
<div className="min-h-screen flex flex-col items-center justify-center px-4 py-12">
<div className="w-full max-w-md text-center">
{/* Security Emblem */}
<div className="relative inline-flex items-center justify-center mb-6">
<div className="w-16 h-16 rounded-2xl bg-his/10 text-his border border-his/20 dark:bg-his/20 dark:border-his/30 flex items-center justify-center shadow-xs">
<i className="ti ti-shield-lock text-3xl" />
</div>
<span className="absolute -bottom-2 px-2 py-0.5 rounded-full text-[10px] font-mono font-bold bg-rose-500 text-white shadow-xs">
403
</span>
</div>
{/* Status & Title */}
<h1 className="text-2xl sm:text-3xl font-bold tracking-tight text-zinc-900 dark:text-zinc-50 mb-2">
Access Restricted
</h1>
<p className="text-sm text-zinc-600 dark:text-zinc-400 mb-6 leading-relaxed">
You do not have permission to view or manage this resource. This may be due to role restrictions or an unassigned permission set.
</p>
{/* Info Card */}
<div className="p-4 rounded-xl bg-white dark:bg-zinc-900 border border-zinc-200 dark:border-zinc-800 text-left space-y-2 mb-8 shadow-xs">
<div className="flex items-center gap-2 text-xs font-semibold text-zinc-800 dark:text-zinc-200 uppercase tracking-wider">
<Lock size={13} className="text-his shrink-0" />
<span>Permission Required</span>
</div>
<p className="text-xs text-muted-foreground leading-relaxed">
If you need access to this feature, please contact HATs system administrator, Manager or Team Leader to request role privileges.
</p>
</div>
{/* Actions */}
<div className="flex flex-col sm:flex-row items-center justify-center gap-3">
<Link href="/" className="w-full sm:w-auto">
<Button className="w-full sm:w-auto bg-his hover:bg-his/90 text-white font-medium inline-flex items-center justify-center gap-2 shadow-sm">
<Home size={15} />
Return to Homepage
</Button>
</Link>
{session?.user.detail.role.allow_admin_panel &&
<Link href="/admin" className="w-full sm:w-auto">
<Button variant="outline" className="w-full sm:w-auto inline-flex items-center justify-center gap-2 font-medium">
<LayoutDashboard size={15} />
Admin Panel
</Button>
</Link>
}
</div>
{/* Switch Account Option */}
<div className="mt-6 pt-4 border-t border-zinc-200/60 dark:border-zinc-800/60">
<Link
href="/auth"
className="inline-flex items-center gap-1.5 text-xs text-muted-foreground hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors font-medium"
>
<ArrowLeft size={13} />
Sign in with a different account
</Link>
</div>
</div>
</div>
);
}