From 1a9de06393b38637de0face9bcd480481de9cf33 Mon Sep 17 00:00:00 2001 From: Horacio Daniel Ros Date: Fri, 25 Sep 2026 10:04:16 -0300 Subject: [PATCH] =?UTF-8?q?feat:=20normalizar=20la=20hora=20de=20finalizac?= =?UTF-8?q?i=C3=B3n=20de=20citas=20que=20cruzan=20la=20medianoche=20y=20aj?= =?UTF-8?q?ustar=20la=20l=C3=B3gica=20de=20ordenamiento=20en=20CalendarRow?= =?UTF-8?q?View?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/Models/Appointments/Appointments.ts | 14 ++++++++++++-- .../components/CalendarRowView/CalendarRowView.tsx | 5 ++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/server/src/Models/Appointments/Appointments.ts b/server/src/Models/Appointments/Appointments.ts index 81cfd86..b7af7d3 100644 --- a/server/src/Models/Appointments/Appointments.ts +++ b/server/src/Models/Appointments/Appointments.ts @@ -1131,7 +1131,12 @@ class AppointmentManager implements IAppointmentsManager { serviceId: String(appointment.serviceId), employeeId: String(appointment.employeeId), startTime: appointment.startHour, - endTime: appointment.endHour, + // Cross-midnight appointments store endHour wrapped into 0-23 (e.g. 23:00 -> 01:00 + // stores 1). Normalize it to a >24 value so schedule views can position it. + endTime: + appointment.endHour < appointment.startHour + ? appointment.endHour + 24 + : appointment.endHour, title: isNull(clientName, clientUserName), avatar: clientAvatar, color: isNull(employee.calendarColor, "#ff9900"), @@ -1257,16 +1262,21 @@ class AppointmentManager implements IAppointmentsManager { //get min startTime hour from returnData let minStartTime = 24; + let maxEndTime = 24; for (const event of returnData) { if (event.startTime < minStartTime) { minStartTime = event.startTime; } + if (event.endTime > maxEndTime) { + maxEndTime = event.endTime; + } } return { events: returnData, from: Math.floor(minStartTime), - to: 24, + // Extend past 24 when an appointment crosses midnight, so the block keeps its real height. + to: Math.max(24, Math.ceil(maxEndTime)), }; } diff --git a/txclient/src/app/components/CalendarRowView/CalendarRowView.tsx b/txclient/src/app/components/CalendarRowView/CalendarRowView.tsx index 7923785..3bac53e 100644 --- a/txclient/src/app/components/CalendarRowView/CalendarRowView.tsx +++ b/txclient/src/app/components/CalendarRowView/CalendarRowView.tsx @@ -12,6 +12,7 @@ export interface CalendarRowViewProps { type CalendarRowViewData = { name: string; + startTime: number; events: TXCalendarEvent[]; }; @@ -167,11 +168,13 @@ export default function CalendarRowView(props: CalendarRowViewProps) { } else { auxData.push({ name: time, + startTime: item.startTime, events: [item], }); } } - setData(auxData.sort((a, b) => a.name.localeCompare(b.name))); + // Sort by numeric hour, never by the formatted label: as strings "11:00 PM" < "5:00 PM". + setData(auxData.sort((a, b) => a.startTime - b.startTime)); }, [daySchedules]); return (