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.8 KiB
TypeScript
52 lines
1.8 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: "Access Permissions | Admin",
|
|
description: "Manage access permissions for role-based access control",
|
|
};
|
|
|
|
async function getPermissions() {
|
|
try {
|
|
const res = await fetchData('/permission', 'no-cache');
|
|
if (Array.isArray(res)) return res;
|
|
if (res && Array.isArray(res.permission)) return res.permission;
|
|
if (res && Array.isArray(res.permissions)) return res.permissions;
|
|
return [];
|
|
} catch (error) {
|
|
console.error('Failed to load permissions:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export default async function PermissionPage() {
|
|
const permissions = await getPermissions();
|
|
|
|
return (
|
|
<div className="flex flex-col">
|
|
<Card>
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
|
<div>
|
|
<CardTitle>Access Permissions</CardTitle>
|
|
<CardDescription className="mt-1">
|
|
List of action permissions for Role-Based Access Control
|
|
</CardDescription>
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ComponentPage data={permissions} />
|
|
</Suspense>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|