import { GetConfiguration } from '@nitrots/nitro-renderer'; import { FC, useMemo } from 'react'; import loadingGif from '@/assets/images/loading/loading.gif'; import nitroV3Logo from '@/assets/images/notifications/nitro_v3.png'; import { Base, Column, Text } from '../../common'; interface LoadingViewProps { isError?: boolean; message?: string; homeUrl?: string; progress?: number; currentTask?: string; } const resolveConfigUrl = (key: string): string => { try { const raw = GetConfiguration().getValue(key, ''); if(!raw) return ''; const interpolated = GetConfiguration().interpolate(raw) || raw; return interpolated; } catch { return ''; } }; const resolveConfigString = (key: string, fallback = ''): string => { try { const raw = GetConfiguration().getValue(key, ''); if(!raw) return fallback; return raw; } catch { return fallback; } }; export const LoadingView: FC = props => { const { isError = false, message = '', homeUrl = '', progress, currentTask = '' } = props; const customLogoUrl = useMemo(() => resolveConfigUrl('loading.logo.url'), []); const customBackground = useMemo(() => resolveConfigString('loading.background', ''), []); const progressBarColor = useMemo(() => resolveConfigString('loading.progress.color', 'linear-gradient(90deg,#4f8cff,#2563eb)'), []); const clampedProgress = typeof progress === 'number' && Number.isFinite(progress) ? Math.max(0, Math.min(100, Math.round(progress))) : null; const backgroundStyle = customBackground ? { background: customBackground } : undefined; const backgroundClassName = customBackground ? 'fixed inset-0 z-[2147483000]' : 'fixed inset-0 z-[2147483000] bg-[radial-gradient(#1d1a24,#003a6b)]'; return ( Nitro V3 { isError && (message && message.length) ? { message } { homeUrl && Back to Hotel } : <> { message && message.length ? { message } : null } { clampedProgress !== null && { clampedProgress }% { currentTask } } } ); };