diff --git a/app/error.tsx b/app/error.tsx index ac7d498..b8d571a 100644 --- a/app/error.tsx +++ b/app/error.tsx @@ -1,7 +1,8 @@ 'use client'; -import React, { useEffect } from 'react'; -import { AlertTriangle, RefreshCw } from 'lucide-react'; +import React, { useEffect, useState } from 'react'; +import { RefreshCw, Home, ChevronDown } from 'lucide-react'; +import Link from 'next/link'; interface ErrorProps { error: Error & { digest?: string }; @@ -9,27 +10,168 @@ interface ErrorProps { } export default function Error({ error, reset }: ErrorProps) { + const [isRetrying, setIsRetrying] = useState(false); + const [showDetails, setShowDetails] = useState(false); + useEffect(() => { console.error('Storefront error boundary caught:', error); + + // Auto-recover from chunk load errors caused by production redeployments + const msg = (error?.message || '').toLowerCase(); + const isChunkError = + error?.name === 'ChunkLoadError' || + msg.includes('loading chunk') || + msg.includes('failed to fetch dynamically imported module'); + + if (isChunkError && typeof window !== 'undefined') { + const retryKey = `chunk_reload_${window.location.pathname}`; + const hasRetried = sessionStorage.getItem(retryKey); + if (!hasRetried) { + sessionStorage.setItem(retryKey, '1'); + window.location.reload(); + } + } }, [error]); + const handleRefresh = () => { + setIsRetrying(true); + if (typeof window !== 'undefined') { + window.location.reload(); + } else { + reset(); + } + }; + return ( -
-
-
- +
+
+ {/* Top Navy Banner matching Image 2 */} +
+ {/* White Circular Badge with crossed wrench & screwdriver */} +
+ + {/* Long 45-deg flat shadow */} + + {/* Screwdriver (top-left to bottom-right) */} + + + + + + + + {/* Wrench (bottom-left to top-right) */} + + + + + + + +
+ + {/* Heading Text */} +
+ WEBSITE
+ UNDER
+ MAINTENANCE +
+
+ + {/* Bottom Content Body */} +
+

+ We’ll be back soon! +

+

+ Sorry for the inconvenience but we're performing some maintenance at the moment. If you need to you can always{' '} + + contact us + + , otherwise we'll be back online shortly! +

+ +

+ — The iFixKart Team +

+ + {/* Action Buttons */} +
+ + + + + Return Home + +
+ + {/* Technical Diagnostics (Collapsible for dev & debugging) */} + {error?.message && ( +
+ + {showDetails && ( +
+

{error.name || 'Error'}: {error.message}

+ {error.digest &&

Digest: {error.digest}

} +
+ )} +
+ )}
-

Something Went Wrong

-

- {error.message || 'We ran into an unexpected error loading this page. Please try refreshing.'} -

-
); diff --git a/app/global-error.tsx b/app/global-error.tsx new file mode 100644 index 0000000..2b5bc4e --- /dev/null +++ b/app/global-error.tsx @@ -0,0 +1,118 @@ +'use client'; + +import React, { useEffect, useState } from 'react'; +import { RefreshCw, Home } from 'lucide-react'; + +interface GlobalErrorProps { + error: Error & { digest?: string }; + reset: () => void; +} + +export default function GlobalError({ error, reset }: GlobalErrorProps) { + const [isRetrying, setIsRetrying] = useState(false); + + useEffect(() => { + console.error('Global error boundary caught:', error); + + const msg = (error?.message || '').toLowerCase(); + const isChunkError = + error?.name === 'ChunkLoadError' || + msg.includes('loading chunk') || + msg.includes('failed to fetch dynamically imported module'); + + if (isChunkError && typeof window !== 'undefined') { + const retryKey = `chunk_reload_global_${window.location.pathname}`; + if (!sessionStorage.getItem(retryKey)) { + sessionStorage.setItem(retryKey, '1'); + window.location.reload(); + } + } + }, [error]); + + const handleRefresh = () => { + setIsRetrying(true); + if (typeof window !== 'undefined') { + window.location.reload(); + } else { + reset(); + } + }; + + return ( + + + + + Website Under Maintenance | iFixKart + + + +
+
+
+ + + + + + + + + + + + + + + + +
+
+ WEBSITE
+ UNDER
+ MAINTENANCE +
+
+
+
We’ll be back soon!
+

+ Sorry for the inconvenience but we're performing some maintenance at the moment. If you need to you can always{' '} + + contact us + + , otherwise we'll be back online shortly! +

+
— The iFixKart Team
+
+ + + + Return Home + +
+
+
+ + + ); +}