2025-11-09 08:52:10 +00:00
import React , { useState } from 'react' ;
import { WizardStep , WizardStepProps } from '../../../ui/WizardModal/WizardModal' ;
2025-11-09 09:01:18 +00:00
import { Wrench , CheckCircle2 , Loader2 } from 'lucide-react' ;
import { useTenant } from '../../../../stores/tenant.store' ;
import { equipmentService } from '../../../../api/services/equipment' ;
2025-11-09 21:22:41 +00:00
import { showToast } from '../../../../utils/toast' ;
feat: Add JTBD-driven Unified Add Wizard system
Implemented a comprehensive unified wizard system to consolidate all "add new content"
actions into a single, intuitive, step-by-step guided experience based on Jobs To Be Done
(JTBD) methodology.
## What's New
### Core Components
- **UnifiedAddWizard**: Main orchestrator component that routes to specific wizards
- **ItemTypeSelector**: Beautiful visual card-based selection for 9 content types
- **9 Individual Wizards**: Step-by-step flows for each content type
### Priority Implementations (P0)
1. **SalesEntryWizard** ⭐ (MOST CRITICAL)
- Manual entry with dynamic product lists and auto-calculated totals
- File upload placeholder for CSV/Excel bulk import
- Critical for small bakeries without POS systems
2. **InventoryWizard**
- Type selection (ingredient vs finished product)
- Context-aware forms based on inventory type
- Optional initial lot entry
### Placeholder Wizards (P1/P2)
- Customer Order, Supplier, Recipe, Customer, Quality Template, Equipment, Team Member
- Proper structure in place for incremental enhancement
### Dashboard Integration
- Added prominent "Agregar" button in dashboard header
- Opens wizard modal with visual type selection
- Auto-refreshes dashboard after wizard completion
### Design Highlights
- Mobile-first responsive design (full-screen on mobile, modal on desktop)
- Touch-friendly with 44px+ touch targets
- Follows existing color system and design tokens
- Progressive disclosure to reduce cognitive load
- Accessibility-compliant (WCAG AA)
## Documentation
Created comprehensive documentation:
- `JTBD_UNIFIED_ADD_WIZARD.md` - Full JTBD analysis and research
- `WIZARD_ARCHITECTURE_DESIGN.md` - Technical design and specifications
- `UNIFIED_WIZARD_IMPLEMENTATION_SUMMARY.md` - Implementation guide
## Files Changed
- New: `frontend/src/components/domain/unified-wizard/` (15 new files)
- Modified: `frontend/src/pages/app/DashboardPage.tsx` (added wizard integration)
## Next Steps
- [ ] Connect wizards to real API endpoints (currently mock/placeholder)
- [ ] Implement full CSV upload for sales entry
- [ ] Add comprehensive form validation
- [ ] Enhance P1 priority wizards based on user feedback
## JTBD Alignment
Main Job: "When I need to expand or update my bakery operations, I want to quickly add
new resources to my management system, so I can keep my business running smoothly."
Key insights applied:
- Prioritized sales entry (most bakeries lack POS)
- Mobile-first (bakery owners are on their feet)
- Progressive disclosure (reduce overwhelm)
- Forgiving interactions (can go back, save drafts)
2025-11-09 08:40:01 +00:00
2025-11-09 08:52:10 +00:00
interface WizardDataProps extends WizardStepProps {
data : Record < string , any > ;
onDataChange : ( data : Record < string , any > ) = > void ;
}
const EquipmentDetailsStep : React.FC < WizardDataProps > = ( { data , onDataChange , onComplete } ) = > {
2025-11-09 09:01:18 +00:00
const { currentTenant } = useTenant ( ) ;
2025-11-09 08:52:10 +00:00
const [ equipmentData , setEquipmentData ] = useState ( {
type : data . type || 'oven' ,
brand : data.brand || '' ,
model : data.model || '' ,
location : data.location || '' ,
purchaseDate : data.purchaseDate || '' ,
status : data.status || 'active' ,
} ) ;
2025-11-09 09:01:18 +00:00
const [ loading , setLoading ] = useState ( false ) ;
const [ error , setError ] = useState < string | null > ( null ) ;
const handleSave = async ( ) = > {
if ( ! currentTenant ? . id ) {
setError ( 'No se pudo obtener información del tenant' ) ;
return ;
}
setLoading ( true ) ;
setError ( null ) ;
try {
const equipmentCreateData : any = {
name : ` ${ equipmentData . type } - ${ equipmentData . brand || 'Sin marca' } ` ,
type : equipmentData . type ,
model : equipmentData.brand ,
serialNumber : equipmentData.model ,
location : equipmentData.location ,
status : equipmentData.status ,
installDate : equipmentData.purchaseDate || new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ,
lastMaintenance : new Date ( ) . toISOString ( ) . split ( 'T' ) [ 0 ] ,
nextMaintenance : new Date ( Date . now ( ) + 30 * 24 * 60 * 60 * 1000 ) . toISOString ( ) . split ( 'T' ) [ 0 ] ,
maintenanceInterval : 30 ,
is_active : true
} ;
await equipmentService . createEquipment ( currentTenant . id , equipmentCreateData ) ;
2025-11-09 21:22:41 +00:00
showToast . success ( 'Equipo creado exitosamente' ) ;
2025-11-09 09:01:18 +00:00
onDataChange ( { . . . data , . . . equipmentData } ) ;
onComplete ( ) ;
} catch ( err : any ) {
console . error ( 'Error creating equipment:' , err ) ;
2025-11-09 21:22:41 +00:00
const errorMessage = err . response ? . data ? . detail || 'Error al crear el equipo' ;
setError ( errorMessage ) ;
showToast . error ( errorMessage ) ;
2025-11-09 09:01:18 +00:00
} finally {
setLoading ( false ) ;
}
} ;
2025-11-09 08:52:10 +00:00
return (
< div className = "space-y-6" >
< div className = "text-center pb-4 border-b border-[var(--border-primary)]" >
< Wrench className = "w-12 h-12 mx-auto mb-3 text-[var(--color-primary)]" / >
< h3 className = "text-lg font-semibold text-[var(--text-primary)] mb-2" > Equipo de Panadería < / h3 >
feat: Add JTBD-driven Unified Add Wizard system
Implemented a comprehensive unified wizard system to consolidate all "add new content"
actions into a single, intuitive, step-by-step guided experience based on Jobs To Be Done
(JTBD) methodology.
## What's New
### Core Components
- **UnifiedAddWizard**: Main orchestrator component that routes to specific wizards
- **ItemTypeSelector**: Beautiful visual card-based selection for 9 content types
- **9 Individual Wizards**: Step-by-step flows for each content type
### Priority Implementations (P0)
1. **SalesEntryWizard** ⭐ (MOST CRITICAL)
- Manual entry with dynamic product lists and auto-calculated totals
- File upload placeholder for CSV/Excel bulk import
- Critical for small bakeries without POS systems
2. **InventoryWizard**
- Type selection (ingredient vs finished product)
- Context-aware forms based on inventory type
- Optional initial lot entry
### Placeholder Wizards (P1/P2)
- Customer Order, Supplier, Recipe, Customer, Quality Template, Equipment, Team Member
- Proper structure in place for incremental enhancement
### Dashboard Integration
- Added prominent "Agregar" button in dashboard header
- Opens wizard modal with visual type selection
- Auto-refreshes dashboard after wizard completion
### Design Highlights
- Mobile-first responsive design (full-screen on mobile, modal on desktop)
- Touch-friendly with 44px+ touch targets
- Follows existing color system and design tokens
- Progressive disclosure to reduce cognitive load
- Accessibility-compliant (WCAG AA)
## Documentation
Created comprehensive documentation:
- `JTBD_UNIFIED_ADD_WIZARD.md` - Full JTBD analysis and research
- `WIZARD_ARCHITECTURE_DESIGN.md` - Technical design and specifications
- `UNIFIED_WIZARD_IMPLEMENTATION_SUMMARY.md` - Implementation guide
## Files Changed
- New: `frontend/src/components/domain/unified-wizard/` (15 new files)
- Modified: `frontend/src/pages/app/DashboardPage.tsx` (added wizard integration)
## Next Steps
- [ ] Connect wizards to real API endpoints (currently mock/placeholder)
- [ ] Implement full CSV upload for sales entry
- [ ] Add comprehensive form validation
- [ ] Enhance P1 priority wizards based on user feedback
## JTBD Alignment
Main Job: "When I need to expand or update my bakery operations, I want to quickly add
new resources to my management system, so I can keep my business running smoothly."
Key insights applied:
- Prioritized sales entry (most bakeries lack POS)
- Mobile-first (bakery owners are on their feet)
- Progressive disclosure (reduce overwhelm)
- Forgiving interactions (can go back, save drafts)
2025-11-09 08:40:01 +00:00
< / div >
2025-11-09 09:01:18 +00:00
{ error && (
< div className = "p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm" >
{ error }
< / div >
) }
2025-11-09 08:52:10 +00:00
< div className = "grid grid-cols-1 md:grid-cols-2 gap-4" >
< div >
< label className = "block text-sm font-medium text-[var(--text-secondary)] mb-2" > Tipo de Equipo * < / label >
2025-11-09 09:01:18 +00:00
< select
value = { equipmentData . type }
onChange = { ( e ) = > setEquipmentData ( { . . . equipmentData , type : e . target . value } ) }
2025-11-09 21:25:36 +00:00
className = "w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]"
2025-11-09 09:01:18 +00:00
>
2025-11-09 08:52:10 +00:00
< option value = "oven" > Horno < / option >
< option value = "mixer" > Amasadora < / option >
< option value = "proofer" > Fermentadora < / option >
< option value = "refrigerator" > Refrigerador < / option >
< option value = "other" > Otro < / option >
< / select >
< / div >
< div >
< label className = "block text-sm font-medium text-[var(--text-secondary)] mb-2" > Marca / Modelo < / label >
2025-11-09 09:01:18 +00:00
< input
type = "text"
value = { equipmentData . brand }
onChange = { ( e ) = > setEquipmentData ( { . . . equipmentData , brand : e.target.value } ) }
placeholder = "Ej: Rational SCC 101"
2025-11-09 21:25:36 +00:00
className = "w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]"
2025-11-09 09:01:18 +00:00
/ >
2025-11-09 08:52:10 +00:00
< / div >
< div >
< label className = "block text-sm font-medium text-[var(--text-secondary)] mb-2" > Ubicación < / label >
2025-11-09 09:01:18 +00:00
< input
type = "text"
value = { equipmentData . location }
onChange = { ( e ) = > setEquipmentData ( { . . . equipmentData , location : e.target.value } ) }
placeholder = "Ej: Cocina principal"
2025-11-09 21:25:36 +00:00
className = "w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]"
2025-11-09 09:01:18 +00:00
/ >
2025-11-09 08:52:10 +00:00
< / div >
< div >
< label className = "block text-sm font-medium text-[var(--text-secondary)] mb-2" > Fecha de Compra < / label >
2025-11-09 09:01:18 +00:00
< input
type = "date"
value = { equipmentData . purchaseDate }
onChange = { ( e ) = > setEquipmentData ( { . . . equipmentData , purchaseDate : e.target.value } ) }
2025-11-09 21:25:36 +00:00
className = "w-full px-3 py-2 border border-[var(--border-secondary)] rounded-lg focus:outline-none focus:ring-2 focus:ring-[var(--color-primary)] bg-[var(--bg-primary)] text-[var(--text-primary)]"
2025-11-09 09:01:18 +00:00
/ >
2025-11-09 08:52:10 +00:00
< / div >
feat: Add JTBD-driven Unified Add Wizard system
Implemented a comprehensive unified wizard system to consolidate all "add new content"
actions into a single, intuitive, step-by-step guided experience based on Jobs To Be Done
(JTBD) methodology.
## What's New
### Core Components
- **UnifiedAddWizard**: Main orchestrator component that routes to specific wizards
- **ItemTypeSelector**: Beautiful visual card-based selection for 9 content types
- **9 Individual Wizards**: Step-by-step flows for each content type
### Priority Implementations (P0)
1. **SalesEntryWizard** ⭐ (MOST CRITICAL)
- Manual entry with dynamic product lists and auto-calculated totals
- File upload placeholder for CSV/Excel bulk import
- Critical for small bakeries without POS systems
2. **InventoryWizard**
- Type selection (ingredient vs finished product)
- Context-aware forms based on inventory type
- Optional initial lot entry
### Placeholder Wizards (P1/P2)
- Customer Order, Supplier, Recipe, Customer, Quality Template, Equipment, Team Member
- Proper structure in place for incremental enhancement
### Dashboard Integration
- Added prominent "Agregar" button in dashboard header
- Opens wizard modal with visual type selection
- Auto-refreshes dashboard after wizard completion
### Design Highlights
- Mobile-first responsive design (full-screen on mobile, modal on desktop)
- Touch-friendly with 44px+ touch targets
- Follows existing color system and design tokens
- Progressive disclosure to reduce cognitive load
- Accessibility-compliant (WCAG AA)
## Documentation
Created comprehensive documentation:
- `JTBD_UNIFIED_ADD_WIZARD.md` - Full JTBD analysis and research
- `WIZARD_ARCHITECTURE_DESIGN.md` - Technical design and specifications
- `UNIFIED_WIZARD_IMPLEMENTATION_SUMMARY.md` - Implementation guide
## Files Changed
- New: `frontend/src/components/domain/unified-wizard/` (15 new files)
- Modified: `frontend/src/pages/app/DashboardPage.tsx` (added wizard integration)
## Next Steps
- [ ] Connect wizards to real API endpoints (currently mock/placeholder)
- [ ] Implement full CSV upload for sales entry
- [ ] Add comprehensive form validation
- [ ] Enhance P1 priority wizards based on user feedback
## JTBD Alignment
Main Job: "When I need to expand or update my bakery operations, I want to quickly add
new resources to my management system, so I can keep my business running smoothly."
Key insights applied:
- Prioritized sales entry (most bakeries lack POS)
- Mobile-first (bakery owners are on their feet)
- Progressive disclosure (reduce overwhelm)
- Forgiving interactions (can go back, save drafts)
2025-11-09 08:40:01 +00:00
< / div >
2025-11-09 09:01:18 +00:00
2025-11-09 08:52:10 +00:00
< div className = "flex justify-end pt-4 border-t border-[var(--border-primary)]" >
2025-11-09 09:01:18 +00:00
< button
onClick = { handleSave }
disabled = { loading }
className = "px-8 py-3 bg-green-600 text-white rounded-lg hover:bg-green-700 font-semibold inline-flex items-center gap-2 disabled:opacity-50 disabled:cursor-not-allowed"
>
{ loading ? (
< >
< Loader2 className = "w-5 h-5 animate-spin" / >
Guardando . . .
< / >
) : (
< >
< CheckCircle2 className = "w-5 h-5" / >
Agregar Equipo
< / >
) }
< / button >
2025-11-09 08:52:10 +00:00
< / div >
< / div >
) ;
} ;
export const EquipmentWizardSteps = ( data : Record < string , any > , setData : ( data : Record < string , any > ) = > void ) : WizardStep [ ] = > [
{ id : 'equipment-details' , title : 'Detalles del Equipo' , description : 'Tipo, modelo, ubicación' , component : ( props ) = > < EquipmentDetailsStep { ...props } data = { data } onDataChange = { setData } / > } ,
feat: Add JTBD-driven Unified Add Wizard system
Implemented a comprehensive unified wizard system to consolidate all "add new content"
actions into a single, intuitive, step-by-step guided experience based on Jobs To Be Done
(JTBD) methodology.
## What's New
### Core Components
- **UnifiedAddWizard**: Main orchestrator component that routes to specific wizards
- **ItemTypeSelector**: Beautiful visual card-based selection for 9 content types
- **9 Individual Wizards**: Step-by-step flows for each content type
### Priority Implementations (P0)
1. **SalesEntryWizard** ⭐ (MOST CRITICAL)
- Manual entry with dynamic product lists and auto-calculated totals
- File upload placeholder for CSV/Excel bulk import
- Critical for small bakeries without POS systems
2. **InventoryWizard**
- Type selection (ingredient vs finished product)
- Context-aware forms based on inventory type
- Optional initial lot entry
### Placeholder Wizards (P1/P2)
- Customer Order, Supplier, Recipe, Customer, Quality Template, Equipment, Team Member
- Proper structure in place for incremental enhancement
### Dashboard Integration
- Added prominent "Agregar" button in dashboard header
- Opens wizard modal with visual type selection
- Auto-refreshes dashboard after wizard completion
### Design Highlights
- Mobile-first responsive design (full-screen on mobile, modal on desktop)
- Touch-friendly with 44px+ touch targets
- Follows existing color system and design tokens
- Progressive disclosure to reduce cognitive load
- Accessibility-compliant (WCAG AA)
## Documentation
Created comprehensive documentation:
- `JTBD_UNIFIED_ADD_WIZARD.md` - Full JTBD analysis and research
- `WIZARD_ARCHITECTURE_DESIGN.md` - Technical design and specifications
- `UNIFIED_WIZARD_IMPLEMENTATION_SUMMARY.md` - Implementation guide
## Files Changed
- New: `frontend/src/components/domain/unified-wizard/` (15 new files)
- Modified: `frontend/src/pages/app/DashboardPage.tsx` (added wizard integration)
## Next Steps
- [ ] Connect wizards to real API endpoints (currently mock/placeholder)
- [ ] Implement full CSV upload for sales entry
- [ ] Add comprehensive form validation
- [ ] Enhance P1 priority wizards based on user feedback
## JTBD Alignment
Main Job: "When I need to expand or update my bakery operations, I want to quickly add
new resources to my management system, so I can keep my business running smoothly."
Key insights applied:
- Prioritized sales entry (most bakeries lack POS)
- Mobile-first (bakery owners are on their feet)
- Progressive disclosure (reduce overwhelm)
- Forgiving interactions (can go back, save drafts)
2025-11-09 08:40:01 +00:00
] ;