import { type Metadata } from 'next'; import { FC, Suspense, lazy } from 'react'; import { getServerSession } from 'next-auth'; import { Download } from 'lucide-react' import { Button } from '@/components/ui/button'; import { type ResponseData } from '@/types/types'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card'; import LazyLoading from '@/components/loader/LazyLoading'; import { authOptions } from '@/lib/auth'; const ComponentPage = lazy(() => import('./component')); export const metadata: Metadata = { title: "Admin | Area", } async function getData() { const { BASE_URL_API } = process.env const session = await getServerSession(authOptions) const res = await fetch(BASE_URL_API + '/area', { headers: { "Content-Type": "application/json", Authorization: `Bearer ${session?.user.access_token}`, }, cache: 'no-cache', next: { tags: ['area'] } }) const data: ResponseData = await res.json() // Recommendation: handle errors if (!res.ok) { // This will activate the closest `error.js` Error Boundary throw new Error(`Failed to fetch data, ${data.code || res.status} ${data.message || res.statusText}`) } return data.data } export default async function AreaPage() { const data = await getData() return ( <>
Area Here's a list of areas that have been registered!
}>
); }