Files
gruperly/apps/backend/src/modules/attendees/lib/helpers.ts
Jose Selesan 2e184845e1 feat: add absence notification and analytics features
- 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.
2026-09-23 16:24:45 -03:00

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;
}