first commit. working
This commit is contained in:
@@ -0,0 +1,18 @@
|
||||
"use client";
|
||||
import React from 'react';
|
||||
import { useAttendance } from '../hooks/useAttendance';
|
||||
|
||||
export default function ClockButton({ teacherId }: { teacherId: string }) {
|
||||
const { todayRecords, clockToggle } = useAttendance();
|
||||
const last = todayRecords.filter(r => r.teacherId === teacherId).pop();
|
||||
const nextType = last?.type === 'in' ? 'out' : 'in';
|
||||
|
||||
return (
|
||||
<button
|
||||
onClick={() => clockToggle(teacherId)}
|
||||
className="px-4 py-2 border rounded"
|
||||
>
|
||||
{nextType === 'in' ? 'Clock In' : 'Clock Out'}
|
||||
</button>
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user