diff --git a/src/components/admin/OnboardingSchemaEditor.tsx b/src/components/admin/OnboardingSchemaEditor.tsx index 3a6c97d..6785348 100644 --- a/src/components/admin/OnboardingSchemaEditor.tsx +++ b/src/components/admin/OnboardingSchemaEditor.tsx @@ -185,9 +185,25 @@ export default function OnboardingSchemaEditor() { ); }; + // Mirrors the backend check in create_onboarding_config — catches it before + // the round trip so an admin can't accidentally publish a wizard with + // nothing to fill in (checkbox on, but a step never got any fields added). + const validationError = (): string | null => { + if (!enableWizardFlow()) return null; + if (steps().length === 0) return 'Cannot enable the wizard flow with no steps configured.'; + const emptyStep = steps().find((s) => s.type !== 'review' && s.fields.length === 0); + if (emptyStep) return `Cannot enable the wizard flow: step "${emptyStep.title || '(untitled step)'}" has no fields.`; + return null; + }; + const handleSave = async () => { const id = roleId(); if (!id) return; + const error = validationError(); + if (error) { + setMessage(error); + return; + } setSaving(true); setMessage(''); try { @@ -259,9 +275,10 @@ export default function OnboardingSchemaEditor() {