import { Box, Button, Stack, Typography } from '@mui/material'; import { alpha, useTheme } from '@mui/material/styles'; import ArrowBackIcon from '@mui/icons-material/ArrowBack'; import Header from '@blocklet/ui-react/lib/Header'; import { useLocaleContext } from '@arcblock/ux/lib/Locale/context'; import { primaryContrastColor } from '../utils/format'; interface ErrorViewProps { error: string; errorCode?: 'SESSION_EXPIRED' | 'EMPTY_LINE_ITEMS' | 'STOP_ACCEPTING_ORDERS' | null; mode?: string; } // Geometric decoration — organic blobs with embedded wireframe mesh function GeometricDecoration() { const theme = useTheme(); const gridColor = alpha(theme.palette.primary.main, 0.06); return ( {/* Blob layer 1 */} `linear-gradient(45deg, ${alpha(t.palette.primary.main, 0.1)}, ${alpha(t.palette.primary.main, 0.03)})`, filter: 'blur(1px)', animation: 'spin 20s linear infinite', '@keyframes spin': { from: { transform: 'rotate(0deg)' }, to: { transform: 'rotate(360deg)' } }, }} /> {/* Blob layer 2 */} `linear-gradient(135deg, ${alpha(t.palette.primary.main, 0.07)}, ${alpha(t.palette.primary.main, 0.01)})`, filter: 'blur(1px)', transform: 'scale(0.88)', opacity: 0.6, animation: 'spinReverse 15s linear infinite', '@keyframes spinReverse': { from: { transform: 'scale(0.88) rotate(0deg)' }, to: { transform: 'scale(0.88) rotate(-360deg)' }, }, }} /> {/* Wireframe mesh overlay — clipped to blob shape */} {/* Horizontal lines */} {[52, 87, 122, 157, 192].map((y) => ( ))} {/* Vertical lines */} {[52, 87, 122, 157, 192].map((x) => ( ))} {/* Diagonal accents — sparse, adds depth */} {/* Concentric circles — digital radar feel */} {/* Dot nodes at key intersections */} {[ [122, 87], [157, 87], [87, 122], [122, 122], [157, 122], [192, 122], [87, 157], [122, 157], [157, 157], [122, 192], [157, 192], ].map(([cx, cy]) => ( ))} ); } function getErrorConfig( errorCode: ErrorViewProps['errorCode'], error: string, t: (key: string) => string ): { title: string; description: string; color: string } { if (errorCode === 'SESSION_EXPIRED') { return { title: t('payment.checkout.expired.title'), description: t('payment.checkout.expired.description'), color: '#f59e0b', }; } if (errorCode === 'EMPTY_LINE_ITEMS') { return { title: t('payment.checkout.emptyItems.title'), description: t('payment.checkout.emptyItems.description'), color: '#94a3b8', }; } if (errorCode === 'STOP_ACCEPTING_ORDERS') { return { title: t('payment.checkout.stopAcceptingOrders.title'), description: t('payment.checkout.stopAcceptingOrders.description'), color: '#f59e0b', }; } return { title: t('payment.checkout.error.title'), description: error, color: '#ef4444', }; } function ErrorContent({ error, errorCode = undefined }: { error: string; errorCode?: ErrorViewProps['errorCode'] }) { const { t } = useLocaleContext(); const theme = useTheme(); const { title, description } = getErrorConfig(errorCode, error, t); const primaryColor = theme.palette.primary.main; const appUrl = typeof window !== 'undefined' ? (window as any).blocklet?.appUrl : '/'; return ( {/* Geometric decoration */} {/* Title */} {title} {/* Description */} {description} {/* CTA button — large pill with primary bg */} {appUrl && ( )} ); } export default function ErrorView({ error, errorCode = undefined, mode = 'inline' }: ErrorViewProps) { const theme = useTheme(); const primaryColor = theme.palette.primary.main; const isFullScreen = mode === 'standalone'; // Mesh gradient background (matching reference Version 2) const meshBg = { bgcolor: (t: any) => (t.palette.mode === 'dark' ? 'background.default' : '#f8faff'), backgroundImage: (t: any) => t.palette.mode === 'dark' ? 'none' : `radial-gradient(at 0% 0%, ${alpha(primaryColor, 0.06)} 0px, transparent 50%), radial-gradient(at 100% 0%, ${alpha(primaryColor, 0.04)} 0px, transparent 50%), radial-gradient(at 100% 100%, ${alpha(primaryColor, 0.06)} 0px, transparent 50%), radial-gradient(at 0% 100%, rgba(203,213,225,0.3) 0px, transparent 50%)`, }; if (!isFullScreen) { // Inline (card) mode return ( ); } // Standalone (full-screen) mode return ( {/* Header */}
buildIns.filter((addon: any) => ['locale-selector', 'theme-mode-toggle', 'session-user'].includes(addon.key)) } /> {/* Centered error content */} ); }