/** * This is a debugging component that provides troubleshooting tools * for the email loading process in the Courrier application. * * NOTE: This component should only be used during development for debugging purposes. * It's kept in the codebase for future reference but won't render in production. */ 'use client'; import { Button } from '@/components/ui/button'; import { RefreshCw, AlertCircle, CheckCircle } from 'lucide-react'; interface LoadingFixProps { loading: boolean; isLoadingInitial: boolean; setLoading: (value: boolean) => void; setIsLoadingInitial: (value: boolean) => void; setEmails: (emails: any[]) => void; loadEmails: () => void; emails: any[]; } export function LoadingFix({ loading, isLoadingInitial, setLoading, setIsLoadingInitial, setEmails, loadEmails, emails }: LoadingFixProps) { // Don't render anything in production mode if (process.env.NODE_ENV === 'production') { return null; } const forceResetLoadingStates = () => { console.log('[DEBUG] Force resetting loading states to false'); // Force both loading states to false setLoading(false); setIsLoadingInitial(false); }; const forceTriggerLoad = () => { console.log('[DEBUG] Force triggering a new email load'); setLoading(true); setTimeout(() => { loadEmails(); }, 100); }; const resetEmailState = () => { console.log('[DEBUG] Resetting email state to empty array'); setEmails([]); setTimeout(() => { forceTriggerLoad(); }, 100); }; return (
Debug Tools
Loading State: {loading ? ( Active ) : ( Inactive )}
Initial Loading: {isLoadingInitial ? ( Active ) : ( Inactive )}
Emails Loaded: 0 ? "text-green-500" : "text-red-500"}> {emails.length}
); }