118 lines
5.8 KiB
TypeScript
118 lines
5.8 KiB
TypeScript
'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 (
|
||
<html lang="en">
|
||
<head>
|
||
<meta charSet="utf-8" />
|
||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||
<title>Website Under Maintenance | iFixKart</title>
|
||
<style>{`
|
||
* { box-sizing: border-box; margin: 0; padding: 0; }
|
||
body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; background: #EEF2F6; min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 16px; }
|
||
.card { max-width: 620px; width: 100%; background: #ffffff; border-radius: 16px; overflow: hidden; box-shadow: 0 20px 40px rgba(0,0,0,0.12); }
|
||
.banner { background: #2D4364; padding: 36px 32px; display: flex; align-items: center; gap: 24px; }
|
||
.circle { width: 110px; height: 110px; border-radius: 50%; background: #ffffff; display: flex; align-items: center; justify-content: center; flex-shrink: 0; box-shadow: 0 8px 24px rgba(0,0,0,0.18); overflow: hidden; }
|
||
.banner-title { color: #ffffff; font-weight: 900; text-transform: uppercase; line-height: 1.05; font-size: 32px; letter-spacing: 0.5px; }
|
||
.content { padding: 36px 32px; }
|
||
.headline { font-size: 24px; font-weight: 800; color: #1E293B; margin-bottom: 14px; }
|
||
.paragraph { font-size: 15px; line-height: 1.6; color: #475569; margin-bottom: 20px; }
|
||
.contact-link { color: #D97706; text-decoration: underline; font-weight: 600; }
|
||
.sign { font-size: 15px; font-weight: 600; color: #64748B; margin-bottom: 28px; }
|
||
.actions { display: flex; flex-wrap: wrap; gap: 12px; }
|
||
.btn-primary { background: #2D4364; color: #ffffff; border: none; padding: 12px 24px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
|
||
.btn-primary:hover { background: #1E293B; }
|
||
.btn-secondary { background: #F1F5F9; color: #334155; border: 1px solid #CBD5E1; padding: 12px 24px; border-radius: 8px; font-weight: 700; font-size: 14px; cursor: pointer; display: inline-flex; align-items: center; gap: 8px; text-decoration: none; }
|
||
.btn-secondary:hover { background: #E2E8F0; }
|
||
`}</style>
|
||
</head>
|
||
<body>
|
||
<div className="card">
|
||
<div className="banner">
|
||
<div className="circle">
|
||
<svg viewBox="0 0 100 100" width="85" height="85" fill="none">
|
||
<polygon points="38,38 98,98 100,80 100,50 62,12 50,24" fill="#E2E8F0" opacity="0.8" />
|
||
<g transform="rotate(-45 50 50)">
|
||
<rect x="48" y="14" width="4" height="36" fill="#2D4364" />
|
||
<polygon points="46,14 54,14 52,9 48,9" fill="#2D4364" />
|
||
<rect x="43" y="50" width="14" height="34" rx="3" fill="#2D4364" />
|
||
<line x1="47" y1="55" x2="47" y2="79" stroke="#FFFFFF" strokeWidth="1.5" strokeLinecap="round" opacity="0.3" />
|
||
<line x1="53" y1="55" x2="53" y2="79" stroke="#FFFFFF" strokeWidth="1.5" strokeLinecap="round" opacity="0.3" />
|
||
</g>
|
||
<g transform="rotate(45 50 50)">
|
||
<rect x="45.5" y="28" width="9" height="40" rx="2" fill="#2D4364" />
|
||
<path d="M36 26 C36 14 42 9 50 9 C58 9 64 14 64 26 C64 29 62 31 57 31 L55 21 L45 21 L43 31 C38 31 36 29 36 26 Z" fill="#2D4364" />
|
||
<circle cx="50" cy="74" r="9" fill="#2D4364" />
|
||
<circle cx="50" cy="74" r="4.5" fill="white" />
|
||
</g>
|
||
</svg>
|
||
</div>
|
||
<div className="banner-title">
|
||
WEBSITE<br />
|
||
UNDER<br />
|
||
MAINTENANCE
|
||
</div>
|
||
</div>
|
||
<div className="content">
|
||
<div className="headline">We’ll be back soon!</div>
|
||
<p className="paragraph">
|
||
Sorry for the inconvenience but we're performing some maintenance at the moment. If you need to you can always{' '}
|
||
<a href="/contact" className="contact-link">
|
||
contact us
|
||
</a>
|
||
, otherwise we'll be back online shortly!
|
||
</p>
|
||
<div className="sign">— The iFixKart Team</div>
|
||
<div className="actions">
|
||
<button type="button" onClick={handleRefresh} disabled={isRetrying} className="btn-primary">
|
||
<RefreshCw size={16} className={isRetrying ? 'animate-spin' : ''} />
|
||
<span>{isRetrying ? 'Refreshing...' : 'Refresh Page'}</span>
|
||
</button>
|
||
<a href="/" className="btn-secondary">
|
||
<Home size={16} />
|
||
<span>Return Home</span>
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</body>
|
||
</html>
|
||
);
|
||
}
|