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.
This commit is contained in:
Jose Selesan
2026-09-23 16:24:45 -03:00
parent a363e9e8fc
commit 2e184845e1
59 changed files with 3854 additions and 23 deletions

View File

@@ -1,8 +1,12 @@
import type {
AbsenceDetails,
AttendeeDto,
AttendeeHistory,
AttendeeList,
AttendeeStatus,
BulkCreateAttendees,
BulkCreateAttendeesResult,
ClassTodayList,
ConnectPayment,
ConnectPaymentResult,
CreateAttendee,
@@ -11,6 +15,7 @@ import type {
CreateFirstGroupResult,
CreateGroupResult,
CreateGroupWaitlistEntry,
GroupAnalytics,
GroupDto,
GroupInviteInfoDto,
GroupList,
@@ -20,11 +25,19 @@ import type {
InviteTokenResult,
JoinGroupViaInvite,
JoinGroupViaInviteResult,
MarkAttendance,
MarkAttendanceResult,
NotifyAbsence,
NotifyAbsenceResult,
OnboardingStatusDto,
ProblemDetails,
PromoteGroupWaitlistEntryResult,
PublicNotifyAbsence,
RemoveAttendeeResult,
RemoveGroupWaitlistEntryResult,
SessionStudents,
StudentsAtRisk,
UpdateStudentStatusResult,
} from '@gruperly/shared'
const API_URL = import.meta.env.VITE_API_URL ?? 'http://localhost:4000'
@@ -89,18 +102,18 @@ export const createGroup = (payload: CreateFirstGroup) =>
export const getGroups = () => apiFetch<GroupList>('/api/v1/groups')
export const getHomeSummary = () => {
let timeZone: string | undefined
function timeZoneParam(): string {
try {
timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
const timeZone = Intl.DateTimeFormat().resolvedOptions().timeZone
return timeZone ? `?timeZone=${encodeURIComponent(timeZone)}` : ''
} catch {
// Sin zona horaria disponible: el backend usa su valor por defecto.
timeZone = undefined
return ''
}
const params = timeZone ? `?timeZone=${encodeURIComponent(timeZone)}` : ''
return apiFetch<HomeSummaryDto>(`/api/v1/home${params}`)
}
export const getHomeSummary = () =>
apiFetch<HomeSummaryDto>(`/api/v1/home${timeZoneParam()}`)
export const getGroup = (groupId: string) =>
apiFetch<GroupDto>(`/api/v1/groups/${groupId}`)
@@ -171,4 +184,50 @@ export const removeGroupAttendee = (
{
method: 'DELETE',
},
)
)
// — Día a Día: clases y asistencia —
export const getClassesToday = () =>
apiFetch<ClassTodayList>(`/api/v1/classes/today${timeZoneParam()}`)
export const getSessionStudents = (sessionId: string) =>
apiFetch<SessionStudents>(`/api/v1/classes/${sessionId}/students${timeZoneParam()}`)
export const markAttendance = (sessionId: string, payload: MarkAttendance) =>
apiFetch<MarkAttendanceResult>(`/api/v1/classes/${sessionId}/attendance`, {
method: 'POST',
body: JSON.stringify(payload),
})
export const notifyAbsence = (sessionId: string, payload: NotifyAbsence) =>
apiFetch<NotifyAbsenceResult>(`/api/v1/classes/${sessionId}/notify-absence`, {
method: 'POST',
body: JSON.stringify(payload),
})
export const getAbsenceDetails = (token: string) =>
apiFetch<AbsenceDetails>(`/api/v1/classes/absence?token=${encodeURIComponent(token)}`)
export const publicNotifyAbsence = (payload: PublicNotifyAbsence) =>
apiFetch<NotifyAbsenceResult>('/api/v1/classes/notify-absence', {
method: 'POST',
body: JSON.stringify(payload),
})
// — Analíticas y gestión de riesgo —
export const getGroupAnalytics = (groupId: string) =>
apiFetch<GroupAnalytics>(`/api/v1/groups/${groupId}/analytics`)
export const getStudentsAtRisk = (groupId: string) =>
apiFetch<StudentsAtRisk>(`/api/v1/groups/${groupId}/students-at-risk`)
export const getAttendeeHistory = (groupId: string, attendeeId: string) =>
apiFetch<AttendeeHistory>(`/api/v1/groups/${groupId}/attendees/${attendeeId}/history`)
export const updateAttendeeStatus = (attendeeId: string, status: AttendeeStatus) =>
apiFetch<UpdateStudentStatusResult>(`/api/v1/students/${attendeeId}/status`, {
method: 'POST',
body: JSON.stringify({ status }),
})