Files
hats-app/app/performance/[id]/page.tsx
T
Ichsan Kurniawan a160eccddf fixing typescript error during production build
Adjust chart components (Overview, PieChart) for sizing and safer typings/casting; add v1.2.0 release note. Remove several obsolete dummy/old task pages and the useDummyTaskData hook. Also include minor fixes to FormClient and DonutChart/performance pages.
2026-04-23 21:36:42 +07:00

60 lines
2.7 KiB
TypeScript

import { FC, Suspense, lazy } from 'react';
import LazyLoading from '@/components/loader/LazyLoading';
import DateRangePicker from './components/DateRangePicker';
import { Metadata } from 'next';
import dayjs from 'dayjs';
import fetchData from '@/lib/fetchData';
import { IUser } from '@/app/admin/administration/user/component/type';
const Header = lazy(() => import('@/app/(dashboard)/components/Header'))
const PerformanceComponent = lazy(() => import('./components'))
type Props = {
params: Promise<{ id: string | undefined }>
searchParams: Promise<{ [key: string]: string | string[] | undefined }>
};
export async function generateMetadata({ params, searchParams }: any): Promise<Metadata> {
const id = (await params).id
const start_date = (await searchParams)!.start_date
const end_date = (await searchParams)!.end_date
const fetchUser: IUser = await fetchData(`/user/${id}`)
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: `${fetchUser.fullname || 'User'}'s Performance in ${date} - HIS Attendance Task System (H.A.T.s)`,
}
}
const PerformancePage: 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 (
<>
<div className='h-screen overflow-y-auto overflow-x-hidden'>
<Suspense fallback={<LazyLoading />}>
<Header />
</Suspense>
<div className='p-6 2xl:w-350 mx-auto space-y-8'>
<div className="flex flex-col sm:flex-row items-start justify-between space-y-2 sm:space-y-0">
<div>
<h1 className="text-lg sm:text-3xl font-medium tracking-tight capitalize">Employee Perfomance</h1>
<p className="text-xs md:text-base text-muted-foreground w-1/2 mt-2 hidden md:block">Here is your store performance, we hope this helps you unlock insights and empower your decision for continues growth.</p>
</div>
<DateRangePicker />
</div>
<Suspense key={`${start_date}${end_date}`} fallback={<div className='w-full h-[70vh] flex justify-center items-center'><LazyLoading /></div>}>
<PerformanceComponent id={id} start_date={start_date as string} end_date={end_date as string} />
</Suspense>
</div>
</div>
</>
);
}
export default PerformancePage;