mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-06 23:36:29 +00:00
1b37ff65f5
Gate administration actions by role permissions, centralize cached session access for data fetching, and return forbidden responses for unauthorized pages. Also lazy-load user exports and adjust search field sizing.
43 lines
1.7 KiB
TypeScript
43 lines
1.7 KiB
TypeScript
import { type Metadata } from 'next';
|
|
import { Suspense, lazy } from 'react';
|
|
import { Download } from 'lucide-react'
|
|
import { Button } from '@/components/ui/button';
|
|
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
import LazyLoading from '@/components/loader/LazyLoading';
|
|
import { getAccessPagePermission } from '@/lib/get-access-data';
|
|
import fetchData from '@/lib/fetchData';
|
|
|
|
const ComponentPage = lazy(() => import('./component'));
|
|
|
|
|
|
export const metadata: Metadata = {
|
|
title: "Admin | Division",
|
|
}
|
|
|
|
export default async function DivisionPage() {
|
|
const actions = await getAccessPagePermission('/administration/division')
|
|
const data = await fetchData('/division', 'no-cache', { tags: ['division'] })
|
|
|
|
return (
|
|
<>
|
|
<div className="flex flex-col">
|
|
<Card>
|
|
<CardHeader className='flex flex-row items-center justify-between space-y-2 sm:space-y-0'>
|
|
<div>
|
|
<CardTitle>Division</CardTitle>
|
|
<CardDescription>Here's a list of departments that have been registered!</CardDescription>
|
|
</div>
|
|
<div className="flex items-center space-x-2">
|
|
<Button className="sm:hidden" size={'icon'}><Download size={20} /></Button>
|
|
</div>
|
|
</CardHeader>
|
|
<CardContent>
|
|
<Suspense fallback={<LazyLoading />}>
|
|
<ComponentPage data={data.division} actions={actions} />
|
|
</Suspense>
|
|
</CardContent>
|
|
</Card>
|
|
</div>
|
|
</>
|
|
);
|
|
} |