- Implemented AbsenceNotifyView for notifying absence with session details. - Created AnalyticsView for displaying group analytics and managing students at risk. - Added ClassAttendanceView for marking attendance in classes. - Defined new schemas for analytics and attendance in shared package.
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import type { AttendeeDto } from '@gruperly/shared';
|
|
|
|
export type AttendeeRecord = {
|
|
id: string;
|
|
groupId: string;
|
|
fullName: string;
|
|
email: string | null;
|
|
phone: string | null;
|
|
guardianName: string | null;
|
|
guardianPhone: string | null;
|
|
notes: string | null;
|
|
notifyToken?: string | null;
|
|
createdAt: Date;
|
|
updatedAt: Date;
|
|
};
|
|
|
|
export function toAttendeeDto(record: AttendeeRecord): AttendeeDto {
|
|
return {
|
|
id: record.id,
|
|
groupId: record.groupId,
|
|
fullName: record.fullName,
|
|
email: record.email,
|
|
phone: record.phone,
|
|
guardianName: record.guardianName,
|
|
guardianPhone: record.guardianPhone,
|
|
notes: record.notes,
|
|
notifyToken: record.notifyToken ?? null,
|
|
createdAt: record.createdAt.toISOString(),
|
|
updatedAt: record.updatedAt.toISOString(),
|
|
};
|
|
}
|
|
|
|
/**
|
|
* Normaliza números de teléfono eliminando espacios, guiones, paréntesis y puntos.
|
|
* Conserva el '+' si lo tiene al inicio para números internacionales.
|
|
*/
|
|
export function normalizePhone(rawPhone: string): string {
|
|
const trimmed = rawPhone.trim();
|
|
const hasPlus = trimmed.startsWith('+');
|
|
const digitsOnly = trimmed.replace(/\D/g, '');
|
|
return hasPlus ? `+${digitsOnly}` : digitsOnly;
|
|
}
|