mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
751b28fab2
Adds permission, menu, and role administration with hierarchical access controls, plus admin breadcrumbs and a redirect from the legacy user-role page. Remove `credentials.md` before committing; it contains server credentials.
59 lines
2.0 KiB
TypeScript
59 lines
2.0 KiB
TypeScript
'use client';
|
|
|
|
import { usePathname } from 'next/navigation';
|
|
import Link from 'next/link';
|
|
|
|
export default function AdminBreadcrumb() {
|
|
const pathname = usePathname();
|
|
|
|
const segments = (pathname || '')
|
|
.split('/')
|
|
.filter(Boolean)
|
|
.slice(1); // skip 'admin'
|
|
|
|
const formatSegment = (seg: string) => {
|
|
return seg
|
|
.split('-')
|
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
.join(' ');
|
|
};
|
|
|
|
if (segments.length === 0) {
|
|
return (
|
|
<div className="flex items-center text-xs font-medium text-muted-foreground">
|
|
<span>Pages</span>
|
|
<span className="mx-1.5 text-zinc-400">/</span>
|
|
<span className="text-zinc-900 dark:text-zinc-100 font-semibold">Dashboard</span>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
return (
|
|
<div className="flex items-center text-xs font-medium text-muted-foreground flex-wrap">
|
|
<Link href="/admin" className="hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors">
|
|
Pages
|
|
</Link>
|
|
{segments.map((seg, idx) => {
|
|
const isLast = idx === segments.length - 1;
|
|
const href = '/admin/' + segments.slice(0, idx + 1).join('/');
|
|
|
|
return (
|
|
<span key={href} className="inline-flex items-center">
|
|
<span className="mx-1.5 text-zinc-400">/</span>
|
|
{isLast ? (
|
|
<span className="text-zinc-900 dark:text-zinc-100 font-semibold">
|
|
{formatSegment(seg)}
|
|
</span>
|
|
) : (
|
|
<Link href={href} className="hover:text-zinc-900 dark:hover:text-zinc-100 transition-colors">
|
|
{formatSegment(seg)}
|
|
</Link>
|
|
)}
|
|
</span>
|
|
);
|
|
})}
|
|
</div>
|
|
);
|
|
}
|
|
|