mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 11:06:29 +00:00
7f8e6637e4
Extract NextAuth configuration into a shared library, load admin sidebar items from role permissions, and update related RBAC types and UI.
47 lines
1.8 KiB
TypeScript
47 lines
1.8 KiB
TypeScript
import { FC, Suspense, lazy } from 'react';
|
|
import InterceptModal from '@/components/modal/InterceptModal';
|
|
import LazyLoading from '@/components/loader/LazyLoading';
|
|
import DateRangePicker from '@/app/performance/[id]/components/DateRangePicker';
|
|
import { getServerSession } from 'next-auth';
|
|
import { Metadata } from 'next';
|
|
import dayjs from 'dayjs';
|
|
import { authOptions } from '@/lib/auth';
|
|
|
|
const PerformanceComponent = lazy(() => import('@/app/performance/[id]/components'));
|
|
|
|
export async function generateMetadata({ searchParams }: any): Promise<Metadata> {
|
|
const session = await getServerSession(authOptions)
|
|
const start_date = (await searchParams)!.start_date
|
|
const end_date = (await searchParams)!.end_date
|
|
|
|
const date = start_date && end_date ? `from ${dayjs(start_date).format('MMM DD, YYYY')} to ${dayjs(end_date).format('MMM DD, YYYY')}` : 'the last 30 days'
|
|
|
|
return {
|
|
title: `${session?.user?.detail.fullname || 'User'}'s Performance in ${date} - HIS Attendance Task System (H.A.T.s)`,
|
|
}
|
|
}
|
|
|
|
type Props = {
|
|
params: Promise<{ id: string | undefined }>
|
|
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
|
|
};
|
|
|
|
const PerformanceModal: FC<Props> = async ({ params, searchParams }) => {
|
|
const id = (await params).id
|
|
const start_date = (await searchParams)!.start_date
|
|
const end_date = (await searchParams)!.end_date
|
|
|
|
return (
|
|
<InterceptModal>
|
|
<div className='space-y-5 mt-10 sm:mt-0'>
|
|
<DateRangePicker />
|
|
|
|
<Suspense key={`${start_date}${end_date}`} fallback={<LazyLoading />}>
|
|
<PerformanceComponent id={id} start_date={start_date as string} end_date={end_date as string} />
|
|
</Suspense>
|
|
</div>
|
|
</InterceptModal>
|
|
);
|
|
}
|
|
|
|
export default PerformanceModal; |