forked from wangziqi/gongxue-base
fix: defer attendance settlement until lesson end
This commit is contained in:
@@ -84,6 +84,30 @@ export function summarizeLessonCheckins(
|
||||
}
|
||||
|
||||
|
||||
export type LessonAttendanceFilter = 'all' | 'checked_in' | 'not_checked_in';
|
||||
|
||||
export interface LessonAttendanceFilterRecord {
|
||||
student: { name: string };
|
||||
status: string;
|
||||
}
|
||||
|
||||
export function filterLessonAttendanceRecords<T extends LessonAttendanceFilterRecord>(
|
||||
records: readonly T[],
|
||||
keyword: string,
|
||||
filter: LessonAttendanceFilter,
|
||||
): T[] {
|
||||
const normalizedKeyword = keyword.trim().toLocaleLowerCase('zh-CN');
|
||||
return records.filter((record) => {
|
||||
const matchesKeyword =
|
||||
!normalizedKeyword ||
|
||||
record.student.name.toLocaleLowerCase('zh-CN').includes(normalizedKeyword);
|
||||
if (!matchesKeyword || filter === 'all') return matchesKeyword;
|
||||
|
||||
const checkedIn = record.status === 'present' || record.status === 'late';
|
||||
return filter === 'checked_in' ? checkedIn : !checkedIn;
|
||||
});
|
||||
}
|
||||
|
||||
export interface PunchDisplayRecord {
|
||||
status: string;
|
||||
source?: string;
|
||||
|
||||
Reference in New Issue
Block a user