import React, { useEffect } from 'react'; import { Container, Paper, Stepper, Progress, Grid, Button, Loader, Group, Text, ThemeIcon, Badge, Box, Alert, rem, } from '@mantine/core'; import { IconX, IconClock, IconCheck, IconRefresh, IconInfoCircle, } from '@tabler/icons-react'; interface OnboardingPanelProps { progressValue: number; onboardNow: boolean; currentStep: number; stepDescriptions: string[]; stepStatuses: ('completed' | 'failed' | 'pending')[]; onboardingSteps: Array<{ id: number; title: string; description: string }>; onStartOnboarding: () => void; onComplete: () => void; } export function OnboardingPanel({ progressValue, onboardNow, currentStep, stepDescriptions, stepStatuses, onboardingSteps, onStartOnboarding, onComplete, }: OnboardingPanelProps) { useEffect(() => { onStartOnboarding(); // eslint-disable-next-line react-hooks/exhaustive-deps }, []); useEffect(() => { if ( currentStep === onboardingSteps.length && stepStatuses[onboardingSteps.length - 1] === 'completed' ) { onComplete(); } }, [currentStep, stepStatuses, onboardingSteps.length, onComplete]); const retryNeeded = stepStatuses.some((s) => s === 'failed'); const completedCount = stepStatuses.filter((s) => s === 'completed').length; const getStepColor = (status: 'completed' | 'failed' | 'pending') => { switch (status) { case 'failed': return 'red'; case 'completed': return 'teal'; default: return 'gray'; } }; const StepStatusIcon = ({ index, status, }: { index: number; status: 'completed' | 'failed' | 'pending'; }) => { if (status === 'failed') { return ( ); } if (status === 'completed') { return ( ); } if (index === currentStep) { return ( ); } return ( ); }; return ( {/* Header Section */} Onboarding Progress {completedCount}/{onboardingSteps.length} Completed {onboardNow && ( {Math.round(progressValue)}% )} {/* Stepper */} {onboardingSteps.map((step, index) => { const status = stepStatuses[index]; return ( } /> ); })} {/* Retry Section */} {retryNeeded && ( <> } title="Some steps need your attention" > A few onboarding steps failed. Please retry to fix them. )} ); }