Files
hats-app/app/admin/page.tsx
T
2025-12-19 13:57:55 +07:00

89 lines
5.4 KiB
TypeScript

import { CalendarDateRangePicker } from '../(dashboard)/components/DaterangePicker';
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
import { fetchDataWithPost } from '@/lib/fetchData';
export default async function AdminDashboardPage() {
const dashboard = fetchDataWithPost('/dashboard', {})
const [dataDashboard] = await Promise.all([dashboard])
return (
<>
<div className="flex flex-col">
<div className="flex-1 space-y-4">
<div className="flex items-center justify-between space-y-2">
<h2 className="text-3xl font-bold tracking-tight">Dashboard</h2>
<div className="flex items-center space-x-2">
<CalendarDateRangePicker />
</div>
</div>
<div className="space-y-5 pb-20 sm:pb-0">
<div className="grid gap-5 sm:grid-cols-2 lg:grid-cols-4">
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">Total Employees</CardTitle>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" className="h-4 w-4 text-muted-foreground" >
<path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2" />
<circle cx="9" cy="7" r="4" />
<path d="M22 21v-2a4 4 0 0 0-3-3.87M16 3.13a4 4 0 0 1 0 7.75" />
</svg>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{dataDashboard?.presence?.total_employee}</div>
<p className="text-xs text-muted-foreground">
number of employee
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Require Approval
</CardTitle>
<i className="ti ti-alarm icon h-4 w-4 text-muted-foreground text-xl"></i>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{dataDashboard?.presence?.need_to_be_approved.total}</div>
<p className="text-xs text-muted-foreground">
number of employee attendance need to be approve
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Employee Birthday
</CardTitle>
<i className="ti ti-clock-play icon h-4 w-4 text-muted-foreground text-xl"></i>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{dataDashboard?.employee_birthday.total}</div>
<p className="text-xs text-muted-foreground">
number of employee
</p>
</CardContent>
</Card>
<Card>
<CardHeader className="flex flex-row items-center justify-between space-y-0 pb-2">
<CardTitle className="text-sm font-medium">
Expiration Contract
</CardTitle>
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" strokeLinecap="round" strokeLinejoin="round" strokeWidth="2" className="h-4 w-4 text-muted-foreground">
<path d="M22 12h-4l-3 9L9 3l-3 9H2" />
</svg>
</CardHeader>
<CardContent>
<div className="text-2xl font-bold">{dataDashboard.employee_contract_expiration.total}</div>
<p className="text-xs text-muted-foreground">
number of employee contract expiration
</p>
</CardContent>
</Card>
</div>
</div>
</div>
</div>
</>
);
}