import { InformationCircleIcon, ExclamationTriangleIcon } from '@heroicons/react/24/solid';
import { MachineStatus } from '../types/machine';
import { getErrorDetails } from '../utils/errorCodeHelpers';
interface NextStepGuideProps {
machineStatus: MachineStatus;
isConnected: boolean;
hasPattern: boolean;
patternUploaded: boolean;
hasError: boolean;
errorMessage?: string;
errorCode?: number;
}
export function NextStepGuide({
machineStatus,
isConnected,
hasPattern,
patternUploaded,
hasError,
errorMessage,
errorCode
}: NextStepGuideProps) {
// Don't show if there's an error - show detailed error guidance instead
if (hasError) {
const errorDetails = getErrorDetails(errorCode);
// Check if this is informational (like initialization steps) vs a real error
if (errorDetails?.isInformational) {
return (
{errorDetails.title}
{errorDetails.description}
{errorDetails.solutions && errorDetails.solutions.length > 0 && (
<>
Steps:
{errorDetails.solutions.map((solution, index) => (
- {solution}
))}
>
)}
);
}
// Regular error display for actual errors
return (
{errorDetails?.title || 'Error Occurred'}
{errorDetails?.description || errorMessage || 'An error occurred. Please check the machine and try again.'}
{errorDetails?.solutions && errorDetails.solutions.length > 0 && (
<>
How to Fix:
{errorDetails.solutions.map((solution, index) => (
- {solution}
))}
>
)}
{errorCode !== undefined && (
Error Code: 0x{errorCode.toString(16).toUpperCase().padStart(2, '0')}
)}
);
}
// Determine what to show based on current state
if (!isConnected) {
return (
Step 1: Connect to Machine
To get started, connect to your Brother embroidery machine via Bluetooth.
- Make sure your machine is powered on
- Enable Bluetooth on your machine
- Click the "Connect to Machine" button below
);
}
if (!hasPattern) {
return (
Step 2: Load Your Pattern
Choose a PES embroidery file from your computer to preview and upload.
- Click "Choose PES File" in the Pattern File section
- Select your embroidery design (.pes file)
- Review the pattern preview on the right
- You can drag the pattern to adjust its position
);
}
if (!patternUploaded) {
return (
Step 3: Upload Pattern to Machine
Send your pattern to the embroidery machine to prepare for sewing.
- Review the pattern preview to ensure it's positioned correctly
- Check the pattern size matches your hoop
- Click "Upload to Machine" when ready
- Wait for the upload to complete (this may take a minute)
);
}
// Pattern is uploaded, guide based on machine status
switch (machineStatus) {
case MachineStatus.IDLE:
return (
Step 4: Start Mask Trace
The mask trace helps the machine understand the pattern boundaries.
- Click "Start Mask Trace" button in the Sewing Progress section
- The machine will trace the pattern outline
- This ensures the hoop is positioned correctly
);
case MachineStatus.MASK_TRACE_LOCK_WAIT:
return (
Machine Action Required
The machine is ready to trace the pattern outline.
- Press the button on your machine to confirm and start the mask trace
- Ensure the hoop is properly attached
- Make sure the needle area is clear
);
case MachineStatus.MASK_TRACING:
return (
Mask Trace In Progress
The machine is tracing the pattern boundary. Please wait...
- Watch the machine trace the outline
- Verify the pattern fits within your hoop
- Do not interrupt the machine
);
case MachineStatus.MASK_TRACE_COMPLETE:
case MachineStatus.SEWING_WAIT:
return (
Step 5: Ready to Sew!
The machine is ready to begin embroidering your pattern.
- Verify your thread colors are correct
- Ensure the fabric is properly hooped
- Click "Start Sewing" when ready
);
case MachineStatus.SEWING:
return (
Step 6: Sewing In Progress
Your embroidery is being stitched. Monitor the progress below.
- Watch the progress bar and current stitch count
- The machine will pause when a color change is needed
- Do not leave the machine unattended
);
case MachineStatus.COLOR_CHANGE_WAIT:
return (
Thread Change Required
The machine needs a different thread color to continue.
- Check the color blocks section to see which thread is needed
- Change to the correct thread color
- Press the button on your machine to resume sewing
);
case MachineStatus.PAUSE:
case MachineStatus.STOP:
case MachineStatus.SEWING_INTERRUPTION:
return (
Sewing Paused
The embroidery has been paused or interrupted.
- Check if everything is okay with the machine
- Click "Resume Sewing" when ready to continue
- The machine will pick up where it left off
);
case MachineStatus.SEWING_COMPLETE:
return (
Step 7: Embroidery Complete!
Your embroidery is finished. Great work!
- Remove the hoop from the machine
- Press the Accept button on the machine
- Carefully remove your finished embroidery
- Trim any jump stitches or loose threads
- Click "Delete Pattern" to start a new project
);
default:
return null;
}
}