import React, { useState } from 'react'; import { AttendanceRecord } from '../types'; import { UserCheck, Search, Filter, Calendar, Clock, MapPin, MoreVertical, Loader2 } from 'lucide-react'; interface AttendanceManagerProps { attendance: AttendanceRecord[]; } const AttendanceManager: React.FC = ({ attendance }) => { const [selectedDate, setSelectedDate] = useState(new Date().toISOString().split('T')[0]); const [isCheckingIn, setIsCheckingIn] = useState(false); const dailyAttendance = attendance.filter(a => a.date === selectedDate); const stats = { present: dailyAttendance.filter(a => a.status === 'PRESENT').length, absent: dailyAttendance.filter(a => a.status === 'ABSENT').length, total: dailyAttendance.length }; const handleGpsCheckIn = () => { setIsCheckingIn(true); if ('geolocation' in navigator) { navigator.geolocation.getCurrentPosition( (position) => { setIsCheckingIn(false); const { latitude, longitude } = position.coords; alert(`GPS Check-in Successful!\nLat: ${latitude.toFixed(6)}\nLng: ${longitude.toFixed(6)}\nLocation verified with site geofence.`); }, (error) => { setIsCheckingIn(false); alert(`Check-in failed: ${error.message}. Please ensure GPS is enabled.`); }, { enableHighAccuracy: true, timeout: 5000, maximumAge: 0 } ); } else { setIsCheckingIn(false); alert('Geolocation is not supported by your browser.'); } }; return (

Attendance & Labor

Track workforce productivity and geofenced attendance.

Present Today

{stats.present}

Total Workforce

{stats.total}

Across all categories

Avg. Productivity

84%

Based on DPR work achieved

Daily Attendance Log

setSelectedDate(e.target.value)} className="px-3 py-2 bg-slate-50 border border-slate-200 rounded-xl text-sm font-medium outline-none focus:ring-2 focus:ring-blue-500" />
{dailyAttendance.length === 0 ? ( ) : ( dailyAttendance.map(record => ( )) )}
Worker Name Category Check In Check Out Status
No attendance records for this date
{record.workerName.charAt(0)}
{record.workerName}
{record.category} {record.checkIn} {record.checkOut || '--:--'} {record.status}
); }; export default AttendanceManager;