Files
hats-app/app/admin/rbac/user-role/page.tsx
T
Ichsan Kurniawan 279b642a7a Apply RBAC permissions across admin and tasks
Enforce page access and action-level permissions across admin and task views, including exports and record actions. Move user creation to a client component behind server-side permission checks, standardize data fetching, and remove the deprecated user-role route.
2026-11-09 17:32:31 +07:00

54 lines
1.9 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';
import { getAccessPagePermission } from '@/lib/get-access-data';
const ComponentPage = lazy(() => import('./component'));
export const dynamic = 'force-dynamic';
export const metadata: Metadata = {
title: "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 actions = await getAccessPagePermission('/rbac/user-role');
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>Role Management</CardTitle>
<CardDescription className="mt-1">
List of registered user roles and permission configurations
</CardDescription>
</div>
</CardHeader>
<CardContent>
<Suspense fallback={<LazyLoading />}>
<ComponentPage data={roles} actions={actions} />
</Suspense>
</CardContent>
</Card>
</div>
);
}