Update fix on attendance
This commit is contained in:
@@ -53,13 +53,22 @@ const getDailyCompletionStats = (date: string, period: Period, attendance: Atten
|
||||
|
||||
export const AttendanceTab: React.FC<Props> = ({ periods, attendance, setManualAttendance, bulkSetManualAttendance, addPendingAttendance, removeAttendanceEntry, activePeriodId, setActivePeriodId, scheduleData }) => {
|
||||
const activePeriod = periods.find(p => p.id === activePeriodId);
|
||||
const [currentDate, setCurrentDate] = useState<string>(activePeriod ? activePeriod.startDate : toIsoDate(new Date()));
|
||||
const [currentDate, setCurrentDate] = useState<string>(() => {
|
||||
const today = toIsoDate(new Date());
|
||||
if (activePeriod && today >= activePeriod.startDate && today <= activePeriod.endDate) return today;
|
||||
return activePeriod ? activePeriod.startDate : today;
|
||||
});
|
||||
|
||||
useEffect(() => {
|
||||
if (activePeriod) {
|
||||
const today = toIsoDate(new Date());
|
||||
if (today >= activePeriod.startDate && today <= activePeriod.endDate) setCurrentDate(today);
|
||||
else setCurrentDate(activePeriod.startDate);
|
||||
setCurrentDate(prevDate => {
|
||||
if (prevDate >= activePeriod.startDate && prevDate <= activePeriod.endDate) {
|
||||
return prevDate;
|
||||
}
|
||||
const today = toIsoDate(new Date());
|
||||
if (today >= activePeriod.startDate && today <= activePeriod.endDate) return today;
|
||||
return activePeriod.startDate;
|
||||
});
|
||||
}
|
||||
}, [activePeriodId, activePeriod]);
|
||||
|
||||
|
||||
Generated
+404
-477
File diff suppressed because it is too large
Load Diff
+11
-2
@@ -16,7 +16,7 @@
|
||||
"dotenv": "^17.3.1",
|
||||
"localforage": "^1.10.0",
|
||||
"lucide-react": "^0.577.0",
|
||||
"next": "16.1.6",
|
||||
"next": "^16.2.1",
|
||||
"react": "19.2.3",
|
||||
"react-dom": "19.2.3",
|
||||
"serwist": "^9.5.7"
|
||||
@@ -28,11 +28,20 @@
|
||||
"@types/pg": "^8.18.0",
|
||||
"@types/react": "^19",
|
||||
"@types/react-dom": "^19",
|
||||
"eslint": "^9",
|
||||
"eslint": "9.14.0",
|
||||
"eslint-config-next": "16.1.6",
|
||||
"prisma": "^7.5.0",
|
||||
"tailwindcss": "^4",
|
||||
"tsx": "^4.21.0",
|
||||
"typescript": "^5"
|
||||
},
|
||||
"overrides": {
|
||||
"hono": "4.12.7",
|
||||
"@hono/node-server": "1.19.10",
|
||||
"effect": "^3.20.0",
|
||||
"@eslint/plugin-kit": "^0.3.4",
|
||||
"brace-expansion": "^5.0.1",
|
||||
"minimatch": "^10.0.0",
|
||||
"lodash": "^4.17.21"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user