feat: normalizar la hora de finalización de citas que cruzan la medianoche y ajustar la lógica de ordenamiento en CalendarRowView

This commit is contained in:
2026-09-25 10:04:16 -03:00
parent ec083ddf42
commit 1a9de06393
2 changed files with 16 additions and 3 deletions
+12 -2
View File
@@ -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<string>(clientName, clientUserName),
avatar: clientAvatar,
color: isNull<string>(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)),
};
}
@@ -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 (