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:
@@ -249,7 +249,7 @@ export function DashboardLayout({ onLogout, currentRoute }: DashboardLayoutProps
|
||||
)
|
||||
case 'scheduling':
|
||||
return (
|
||||
<ErrorBoundary>
|
||||
<ErrorBoundary autoRetry={true} retryDelay={2000} maxRetries={3}>
|
||||
<Suspense fallback={<div className="p-6">Loading scheduling module...</div>}>
|
||||
<RemoteScheduling user={user} currentRoute={currentRoute} />
|
||||
</Suspense>
|
||||
|
||||
@@ -951,18 +951,23 @@ export function HorizontalTimelineCalendar({
|
||||
}).filter((d): d is NonNullable<typeof d> => d !== null)
|
||||
|
||||
// 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 repetitionRows: Array<Array<typeof repetitionData[0]>> = []
|
||||
|
||||
sortedRepetitions.forEach(rep => {
|
||||
let placed = false
|
||||
// Try to place in existing rows first
|
||||
for (let rowIndex = 0; rowIndex < repetitionRows.length; rowIndex++) {
|
||||
const row = repetitionRows[rowIndex]
|
||||
// Check if this repetition overlaps with ANY repetition in this row
|
||||
const hasOverlap = row.some(existingRep => {
|
||||
const threshold = 1
|
||||
return !(rep.right + threshold <= existingRep.left || rep.left - threshold >= existingRep.right)
|
||||
// Two repetitions overlap if they share any horizontal space
|
||||
// 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) {
|
||||
row.push(rep)
|
||||
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) {
|
||||
repetitionRows.push([rep])
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user