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.
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { type Metadata } from 'next';
|
|
import { Suspense, lazy } from 'react';
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
import LazyLoading from '@/components/loader/LazyLoading';
|
|
import fetchData from '@/lib/fetchData';
|
|
|
|
const ComponentPage = lazy(() => import('./component'));
|
|
|
|
export const dynamic = 'force-dynamic';
|
|
|
|
export const metadata: Metadata = {
|
|
title: "User Role Management | Admin",
|
|
description: "Manage system user roles, admin panel access, and menu permissions",
|
|
};
|
|
|
|
async function getRoles() {
|
|
try {
|
|
const res = await fetchData('/role', 'no-cache');
|
|
if (Array.isArray(res)) return res;
|
|
if (res && Array.isArray(res.role)) return res.role;
|
|
if (res && Array.isArray(res.roles)) return res.roles;
|
|
return [];
|
|
} catch (error) {
|
|
console.error('Failed to load roles:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export default async function UserRolePage() {
|
|
const roles = await getRoles();
|
|
|
|
return (
|
|
<div className="flex flex-col">
|
|
<Card>
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
|
<div>
|
|
<CardTitle>User Role</CardTitle>
|
|
<CardDescription className="mt-1">
|
|
List of registered user roles and permission sets
|
|
</CardDescription>
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ComponentPage data={roles} />
|
|
</Suspense>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|