mirror of
https://github.com/ichsankurnia/hats-app.git
synced 2026-12-05 10:46:29 +00:00
a160eccddf
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.
60 lines
2.7 KiB
TypeScript
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; |