import { Alert, AlertDescription, AlertTitle } from '@/components/ui/alert'; import { Button } from '@/components/ui/button'; import { CalendarCheck, CheckCircle2, Clock, LogIn, LogOut } from 'lucide-react'; type TodayAttendance = { id: number; check_in_at: string | null; check_out_at: string | null; } | null; type TodayAttendanceAlertProps = { todayAttendance: TodayAttendance; canCheckIn?: boolean; isOnLeave?: boolean; locationLoading?: boolean; onCheckIn?: () => void; onCheckOut?: () => void; showButtons?: boolean; }; function formatTime(dateStr: string | null): string { if (!dateStr) { return '-'; } return new Date(dateStr).toLocaleTimeString('id-ID', { hour: '2-digit', minute: '2-digit', hour12: false, }); } export function TodayAttendanceAlert({ todayAttendance, canCheckIn = true, isOnLeave = false, locationLoading = false, onCheckIn, onCheckOut, showButtons = true, }: TodayAttendanceAlertProps) { const hasCheckedIn = !!todayAttendance?.check_in_at; const hasCheckedOut = !!todayAttendance?.check_out_at; return ( Presensi Hari Ini
{hasCheckedIn ? (
Masuk: {formatTime(todayAttendance?.check_in_at)}
{hasCheckedOut ? ( <> Pulang: {formatTime(todayAttendance?.check_out_at)} ) : ( <> Pulang: Belum )}
) : isOnLeave ? (

Anda sedang cuti hari ini.

) : !canCheckIn ? (

Anda tidak memiliki akses presensi.

) : (

Anda belum melakukan presensi hari ini

)}
{showButtons && canCheckIn && !isOnLeave && (
)}
); }