feat: Completely rewrite RecipeWizard with comprehensive improvements

Major improvements:
1. Fixed 'a.map is not a function' error (line 387: result.templates)
2. Removed duplicate Next buttons - now using WizardModal's validate prop
3. Added ALL missing required fields (version, difficulty_level, status defaults)
4. Added comprehensive advanced options section with ALL optional fields:
   - Recipe code/SKU, version, difficulty level
   - Cook time, rest time, total time
   - Batch sizing (min/max, multiplier)
   - Production environment (temp, humidity)
   - Seasonal/signature item flags
   - Descriptions, notes, storage instructions
   - Allergens, dietary tags
   - Target margin percentage
5. Integrated AdvancedOptionsSection component for progressive disclosure
6. Added tooltips for complex fields using existing Tooltip component
7. Proper form validation on each step
8. Real-time data synchronization with useEffect
9. English labels (per project standards)
10. All fields map correctly to backend RecipeCreate schema

Technical changes:
- Created reusable AdvancedOptionsSection component
- Steps now validate using WizardModal's validate prop
- No internal "Continuar" buttons - cleaner UX
- Quality Templates step marked as optional (isOptional: true)
- Ingredients step validates all required data
- Seasonal month selectors conditional on isSeasonal checkbox

This implementation follows UX best practices for progressive disclosure and reduces cognitive load while maintaining access to all backend fields.
This commit is contained in:
Claude
2025-11-10 07:28:20 +00:00
parent 020acc4691
commit 3b66bb869a
3 changed files with 642 additions and 152 deletions

View File

@@ -0,0 +1,67 @@
import React, { useState } from 'react';
import { ChevronDown, ChevronUp } from 'lucide-react';
interface AdvancedOptionsSectionProps {
children: React.ReactNode;
title?: string;
description?: string;
defaultExpanded?: boolean;
}
export const AdvancedOptionsSection: React.FC<AdvancedOptionsSectionProps> = ({
children,
title = 'Advanced Options',
description = 'These fields are optional but help improve data management',
defaultExpanded = false,
}) => {
const [isExpanded, setIsExpanded] = useState(defaultExpanded);
return (
<div className="space-y-4">
<button
type="button"
onClick={() => setIsExpanded(!isExpanded)}
className="w-full py-3 px-4 border-2 border-dashed border-[var(--border-secondary)] rounded-lg text-[var(--text-secondary)] hover:border-[var(--color-primary)] hover:text-[var(--color-primary)] transition-colors inline-flex items-center justify-center gap-2 font-medium"
>
{isExpanded ? (
<>
<ChevronUp className="w-5 h-5" />
Hide {title}
</>
) : (
<>
<ChevronDown className="w-5 h-5" />
Show {title}
</>
)}
</button>
{isExpanded && (
<div className="space-y-4 p-4 border border-[var(--border-secondary)] rounded-lg bg-[var(--bg-secondary)]/30 animate-slideDown">
{description && (
<p className="text-sm text-[var(--text-secondary)] pb-2 border-b border-[var(--border-primary)]">
{description}
</p>
)}
{children}
</div>
)}
<style>{`
@keyframes slideDown {
from {
opacity: 0;
transform: translateY(-10px);
}
to {
opacity: 1;
transform: translateY(0);
}
}
.animate-slideDown {
animation: slideDown 0.2s ease-out;
}
`}</style>
</div>
);
};

View File

@@ -0,0 +1 @@
export { AdvancedOptionsSection } from './AdvancedOptionsSection';