- {/* Buttons removed from here to avoid duplication with the BulkActionsToolbar */}
-
+ {/* Buttons removed from here to avoid duplication with the BulkActionsToolbar */}
{/* Email List - Always visible */}
@@ -743,7 +741,23 @@ export default function CourrierPage() {
) : (
{/* Email List */}
-
+
{
+ const target = e.currentTarget;
+ const { scrollTop, scrollHeight, clientHeight } = target;
+ const distanceToBottom = scrollHeight - scrollTop - clientHeight;
+ const scrollPercentage = (scrollTop + clientHeight) / scrollHeight;
+
+ console.log(`[DEBUG-WRAPPER-SCROLL] Distance to bottom: ${distanceToBottom}px, percentage: ${Math.round(scrollPercentage * 100)}%, hasMoreEmails: ${page < totalPages}, isLoading: ${isLoading}`);
+
+ // If near bottom and not already loading and has more emails
+ if (distanceToBottom < 300 && !isLoading && page < totalPages) {
+ console.log(`[DEBUG-WRAPPER-TRIGGER] Calling handleLoadMore from wrapper`);
+ handleLoadMore();
+ }
+ }}
+ >
{emails.length === 0 ? (