Enhance ErrorBoundary and improve repetition placement logic in scheduling components

- Updated ErrorBoundary to include auto-retry functionality with configurable retry parameters.
- Refined repetition placement logic in HorizontalTimelineCalendar to handle overlaps more accurately, ensuring better visual representation of scheduling data.
- Added comments for clarity on sorting and overlap checks within the repetition handling process.
This commit is contained in:
salirezav
2026-01-14 16:41:10 -05:00
parent c54385a90c
commit 780a95549b
2 changed files with 9 additions and 3 deletions

View File

@@ -249,7 +249,7 @@ export function DashboardLayout({ onLogout, currentRoute }: DashboardLayoutProps
) )
case 'scheduling': case 'scheduling':
return ( return (
<ErrorBoundary> <ErrorBoundary autoRetry={true} retryDelay={2000} maxRetries={3}>
<Suspense fallback={<div className="p-6">Loading scheduling module...</div>}> <Suspense fallback={<div className="p-6">Loading scheduling module...</div>}>
<RemoteScheduling user={user} currentRoute={currentRoute} /> <RemoteScheduling user={user} currentRoute={currentRoute} />
</Suspense> </Suspense>

View File

@@ -951,18 +951,23 @@ export function HorizontalTimelineCalendar({
}).filter((d): d is NonNullable<typeof d> => d !== null) }).filter((d): d is NonNullable<typeof d> => d !== null)
// Calculate vertical stacking positions // Calculate vertical stacking positions
// Sort by left position to process from left to right
const sortedRepetitions = [...repetitionData].sort((a, b) => a.left - b.left) const sortedRepetitions = [...repetitionData].sort((a, b) => a.left - b.left)
const repetitionRows: Array<Array<typeof repetitionData[0]>> = [] const repetitionRows: Array<Array<typeof repetitionData[0]>> = []
sortedRepetitions.forEach(rep => { sortedRepetitions.forEach(rep => {
let placed = false let placed = false
// Try to place in existing rows first
for (let rowIndex = 0; rowIndex < repetitionRows.length; rowIndex++) { for (let rowIndex = 0; rowIndex < repetitionRows.length; rowIndex++) {
const row = repetitionRows[rowIndex] const row = repetitionRows[rowIndex]
// Check if this repetition overlaps with ANY repetition in this row
const hasOverlap = row.some(existingRep => { const hasOverlap = row.some(existingRep => {
const threshold = 1 // Two repetitions overlap if they share any horizontal space
return !(rep.right + threshold <= existingRep.left || rep.left - threshold >= existingRep.right) // Overlap occurs when: rep.left < existingRep.right AND rep.right > existingRep.left
return rep.left < existingRep.right && rep.right > existingRep.left
}) })
// If no overlap with any repetition in this row, we can place it here
if (!hasOverlap) { if (!hasOverlap) {
row.push(rep) row.push(rep)
placed = true placed = true
@@ -970,6 +975,7 @@ export function HorizontalTimelineCalendar({
} }
} }
// If couldn't place in any existing row (due to overlaps), create a new row
if (!placed) { if (!placed) {
repetitionRows.push([rep]) repetitionRows.push([rep])
} }