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: "Menu Management | Admin",
|
|
description: "Manage system navigation menus and their permission actions",
|
|
};
|
|
|
|
async function getMenus() {
|
|
try {
|
|
const res = await fetchData('/menu', 'no-cache');
|
|
if (Array.isArray(res)) return res;
|
|
if (res && Array.isArray(res.menu)) return res.menu;
|
|
if (res && Array.isArray(res.menus)) return res.menus;
|
|
return [];
|
|
} catch (error) {
|
|
console.error('Failed to load menus:', error);
|
|
return [];
|
|
}
|
|
}
|
|
|
|
export default async function MenuPage() {
|
|
const menus = await getMenus();
|
|
|
|
return (
|
|
<div className="flex flex-col">
|
|
<Card>
|
|
<CardHeader className="flex flex-row items-center justify-between space-y-0">
|
|
<div>
|
|
<CardTitle>Menu Management</CardTitle>
|
|
<CardDescription className="mt-1">
|
|
List of registered navigation menus and their access permissions
|
|
</CardDescription>
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ComponentPage data={menus} />
|
|
</Suspense>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
);
|
|
}
|