feat: Enhance Quality Template and Recipe wizards with comprehensive features
Quality Template Wizard improvements: - Added comprehensive fields for better template configuration - Frequency details (time of day, specific conditions) - Responsible person/role assignment - Required equipment/tools specification - Detailed acceptance criteria - Special conditions and notes - Photo requirements toggle - Critical control point (PCC) designation - Notification settings for failures - Dynamic description generation from all fields - Improved UI with organized sections Recipe Wizard improvements: - Added quality templates integration step - Fetch and display available quality templates - Multi-select interface for template assignment - Templates linked to recipe via quality_check_configuration - Optional step - can skip if no templates needed - Shows template details (type, frequency, requirements) - Auto-generates quality config for production stage - Seamless integration with existing recipe creation flow Files modified: - frontend/src/components/domain/unified-wizard/wizards/QualityTemplateWizard.tsx - frontend/src/components/domain/unified-wizard/wizards/RecipeWizard.tsx
This commit is contained in:
@@ -17,6 +17,14 @@ const TemplateInfoStep: React.FC<WizardDataProps> = ({ data, onDataChange, onCom
|
||||
name: data.name || '',
|
||||
scope: data.scope || 'product',
|
||||
frequency: data.frequency || 'batch',
|
||||
frequencyTime: data.frequencyTime || '',
|
||||
responsibleRole: data.responsibleRole || '',
|
||||
requiresPhoto: data.requiresPhoto || false,
|
||||
criticalControlPoint: data.criticalControlPoint || false,
|
||||
requiredEquipment: data.requiredEquipment || '',
|
||||
acceptanceCriteria: data.acceptanceCriteria || '',
|
||||
notifyOnFail: data.notifyOnFail || false,
|
||||
specificConditions: data.specificConditions || '',
|
||||
});
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
@@ -38,25 +46,46 @@ const TemplateInfoStep: React.FC<WizardDataProps> = ({ data, onDataChange, onCom
|
||||
safety: 'safety'
|
||||
};
|
||||
|
||||
// Build comprehensive description
|
||||
let description = `Plantilla de ${templateData.scope} con frecuencia ${templateData.frequency}.`;
|
||||
if (templateData.frequencyTime) {
|
||||
description += ` ${templateData.frequencyTime}.`;
|
||||
}
|
||||
if (templateData.responsibleRole) {
|
||||
description += ` Responsable: ${templateData.responsibleRole}.`;
|
||||
}
|
||||
if (templateData.requiredEquipment) {
|
||||
description += ` Equipo requerido: ${templateData.requiredEquipment}.`;
|
||||
}
|
||||
if (templateData.acceptanceCriteria) {
|
||||
description += ` Criterios: ${templateData.acceptanceCriteria}.`;
|
||||
}
|
||||
if (templateData.specificConditions) {
|
||||
description += ` Condiciones: ${templateData.specificConditions}.`;
|
||||
}
|
||||
if (templateData.requiresPhoto) {
|
||||
description += ` Requiere fotografía.`;
|
||||
}
|
||||
|
||||
const templateCreateData: QualityCheckTemplateCreate = {
|
||||
name: templateData.name,
|
||||
description: `Plantilla de ${templateData.scope} con frecuencia ${templateData.frequency}`,
|
||||
description: description,
|
||||
check_type: scopeMapping[templateData.scope] || 'product_quality',
|
||||
applicable_stages: [],
|
||||
check_points: [
|
||||
{
|
||||
name: 'Verificación General',
|
||||
description: 'Punto de verificación inicial',
|
||||
name: templateData.acceptanceCriteria ? 'Verificación de Criterios' : 'Verificación General',
|
||||
description: templateData.acceptanceCriteria || 'Punto de verificación inicial',
|
||||
expected_value: 'Conforme',
|
||||
measurement_type: 'pass_fail',
|
||||
is_critical: false,
|
||||
is_critical: templateData.criticalControlPoint,
|
||||
weight: 1.0
|
||||
}
|
||||
],
|
||||
scoring_method: 'weighted_average',
|
||||
pass_threshold: 70.0,
|
||||
weight: 5.0,
|
||||
is_required: templateData.frequency === 'batch',
|
||||
weight: templateData.criticalControlPoint ? 10.0 : 5.0,
|
||||
is_required: templateData.frequency === 'batch' || templateData.criticalControlPoint,
|
||||
is_active: true,
|
||||
frequency_days: templateData.frequency === 'daily' ? 1 : templateData.frequency === 'weekly' ? 7 : undefined
|
||||
};
|
||||
@@ -89,6 +118,12 @@ const TemplateInfoStep: React.FC<WizardDataProps> = ({ data, onDataChange, onCom
|
||||
</div>
|
||||
)}
|
||||
|
||||
<div className="space-y-6">
|
||||
{/* Basic Information */}
|
||||
<div className="space-y-4">
|
||||
<h4 className="text-sm font-semibold text-[var(--text-primary)] border-b border-[var(--border-secondary)] pb-2">
|
||||
Información Básica
|
||||
</h4>
|
||||
<div className="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div className="md:col-span-2">
|
||||
<label className="block text-sm font-medium text-[var(--text-secondary)] mb-2">Nombre *</label>
|
||||
@@ -125,6 +160,124 @@ const TemplateInfoStep: React.FC<WizardDataProps> = ({ data, onDataChange, onCom
|
||||
<option value="weekly">Semanal</option>
|
||||
</select>
|
||||
</div>
|
||||
<div className="md:col-span-2">
|
||||
<label className="block text-sm font-medium text-[var(--text-secondary)] mb-2">
|
||||
Hora/Condiciones Específicas
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={templateData.frequencyTime}
|
||||
onChange={(e) => setTemplateData({ ...templateData, frequencyTime: e.target.value })}
|
||||
placeholder="Ej: 8:00 AM, antes de hornear, temperatura ambiente"
|
||||
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)]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Responsibility & Requirements */}
|
||||
<div className="space-y-4">
|
||||
<h4 className="text-sm font-semibold text-[var(--text-primary)] border-b border-[var(--border-secondary)] pb-2">
|
||||
Responsabilidad y Requisitos
|
||||
</h4>
|
||||
<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">
|
||||
Persona/Rol Responsable
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={templateData.responsibleRole}
|
||||
onChange={(e) => setTemplateData({ ...templateData, responsibleRole: e.target.value })}
|
||||
placeholder="Ej: Jefe de Producción, Panadero"
|
||||
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)]"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label className="block text-sm font-medium text-[var(--text-secondary)] mb-2">
|
||||
Equipo/Herramientas Requeridas
|
||||
</label>
|
||||
<input
|
||||
type="text"
|
||||
value={templateData.requiredEquipment}
|
||||
onChange={(e) => setTemplateData({ ...templateData, requiredEquipment: e.target.value })}
|
||||
placeholder="Ej: Termómetro, báscula, cronómetro"
|
||||
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)]"
|
||||
/>
|
||||
</div>
|
||||
<div className="md:col-span-2">
|
||||
<label className="block text-sm font-medium text-[var(--text-secondary)] mb-2">
|
||||
Criterios de Aceptación
|
||||
</label>
|
||||
<textarea
|
||||
value={templateData.acceptanceCriteria}
|
||||
onChange={(e) => setTemplateData({ ...templateData, acceptanceCriteria: e.target.value })}
|
||||
placeholder="Ej: Color dorado uniforme, textura esponjosa, sin quemaduras..."
|
||||
rows={3}
|
||||
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)]"
|
||||
/>
|
||||
</div>
|
||||
<div className="md:col-span-2">
|
||||
<label className="block text-sm font-medium text-[var(--text-secondary)] mb-2">
|
||||
Condiciones o Notas Especiales
|
||||
</label>
|
||||
<textarea
|
||||
value={templateData.specificConditions}
|
||||
onChange={(e) => setTemplateData({ ...templateData, specificConditions: e.target.value })}
|
||||
placeholder="Ej: Solo aplicable en días húmedos, verificar 30 min después de hornear..."
|
||||
rows={2}
|
||||
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)]"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* Control Settings */}
|
||||
<div className="space-y-4">
|
||||
<h4 className="text-sm font-semibold text-[var(--text-primary)] border-b border-[var(--border-secondary)] pb-2">
|
||||
Configuración de Control
|
||||
</h4>
|
||||
<div className="space-y-3">
|
||||
<label className="flex items-center gap-3 p-3 bg-[var(--bg-secondary)]/30 rounded-lg border border-[var(--border-secondary)] cursor-pointer hover:bg-[var(--bg-secondary)]/50 transition-colors">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={templateData.requiresPhoto}
|
||||
onChange={(e) => setTemplateData({ ...templateData, requiresPhoto: e.target.checked })}
|
||||
className="w-4 h-4 text-[var(--color-primary)] rounded focus:ring-2 focus:ring-[var(--color-primary)]"
|
||||
/>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-[var(--text-primary)]">Requiere Fotografía</p>
|
||||
<p className="text-xs text-[var(--text-tertiary)]">Se debe adjuntar evidencia fotográfica</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center gap-3 p-3 bg-[var(--bg-secondary)]/30 rounded-lg border border-[var(--border-secondary)] cursor-pointer hover:bg-[var(--bg-secondary)]/50 transition-colors">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={templateData.criticalControlPoint}
|
||||
onChange={(e) => setTemplateData({ ...templateData, criticalControlPoint: e.target.checked })}
|
||||
className="w-4 h-4 text-[var(--color-primary)] rounded focus:ring-2 focus:ring-[var(--color-primary)]"
|
||||
/>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-[var(--text-primary)]">Punto de Control Crítico (PCC)</p>
|
||||
<p className="text-xs text-[var(--text-tertiary)]">Requiere acción inmediata si falla</p>
|
||||
</div>
|
||||
</label>
|
||||
|
||||
<label className="flex items-center gap-3 p-3 bg-[var(--bg-secondary)]/30 rounded-lg border border-[var(--border-secondary)] cursor-pointer hover:bg-[var(--bg-secondary)]/50 transition-colors">
|
||||
<input
|
||||
type="checkbox"
|
||||
checked={templateData.notifyOnFail}
|
||||
onChange={(e) => setTemplateData({ ...templateData, notifyOnFail: e.target.checked })}
|
||||
className="w-4 h-4 text-[var(--color-primary)] rounded focus:ring-2 focus:ring-[var(--color-primary)]"
|
||||
/>
|
||||
<div>
|
||||
<p className="text-sm font-medium text-[var(--text-primary)]">Notificar en Caso de Fallo</p>
|
||||
<p className="text-xs text-[var(--text-tertiary)]">Enviar alerta cuando el control no pase</p>
|
||||
</div>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="flex justify-end pt-4 border-t border-[var(--border-primary)]">
|
||||
|
||||
@@ -4,8 +4,10 @@ import { ChefHat, Package, ClipboardCheck, CheckCircle2, Loader2, Plus, X, Searc
|
||||
import { useTenant } from '../../../../stores/tenant.store';
|
||||
import { recipesService } from '../../../../api/services/recipes';
|
||||
import { inventoryService } from '../../../../api/services/inventory';
|
||||
import { qualityTemplateService } from '../../../../api/services/qualityTemplates';
|
||||
import { IngredientResponse } from '../../../../api/types/inventory';
|
||||
import { RecipeCreate, RecipeIngredientCreate, MeasurementUnit } from '../../../../api/types/recipes';
|
||||
import { RecipeCreate, RecipeIngredientCreate, MeasurementUnit, RecipeQualityConfiguration } from '../../../../api/types/recipes';
|
||||
import { QualityCheckTemplateResponse } from '../../../../api/types/qualityTemplates';
|
||||
import { showToast } from '../../../../utils/toast';
|
||||
|
||||
interface WizardDataProps extends WizardStepProps {
|
||||
@@ -161,12 +163,11 @@ interface SelectedIngredient {
|
||||
order: number;
|
||||
}
|
||||
|
||||
const IngredientsStep: React.FC<WizardDataProps> = ({ data, onDataChange, onComplete }) => {
|
||||
const IngredientsStep: React.FC<WizardDataProps> = ({ data, onDataChange, onNext }) => {
|
||||
const { currentTenant } = useTenant();
|
||||
const [ingredients, setIngredients] = useState<IngredientResponse[]>([]);
|
||||
const [selectedIngredients, setSelectedIngredients] = useState<SelectedIngredient[]>(data.ingredients || []);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
|
||||
@@ -214,12 +215,7 @@ const IngredientsStep: React.FC<WizardDataProps> = ({ data, onDataChange, onComp
|
||||
setSelectedIngredients(selectedIngredients.filter(ing => ing.id !== id));
|
||||
};
|
||||
|
||||
const handleSaveRecipe = async () => {
|
||||
if (!currentTenant?.id) {
|
||||
setError('No se pudo obtener información del tenant');
|
||||
return;
|
||||
}
|
||||
|
||||
const handleContinue = () => {
|
||||
if (selectedIngredients.length === 0) {
|
||||
setError('Debes agregar al menos un ingrediente');
|
||||
return;
|
||||
@@ -234,43 +230,8 @@ const IngredientsStep: React.FC<WizardDataProps> = ({ data, onDataChange, onComp
|
||||
return;
|
||||
}
|
||||
|
||||
setSaving(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Prepare recipe data according to RecipeCreate interface
|
||||
const recipeIngredients: RecipeIngredientCreate[] = selectedIngredients.map((ing, index) => ({
|
||||
ingredient_id: ing.ingredientId,
|
||||
quantity: ing.quantity,
|
||||
unit: ing.unit,
|
||||
ingredient_notes: ing.notes || null,
|
||||
is_optional: false,
|
||||
ingredient_order: index + 1,
|
||||
}));
|
||||
|
||||
const recipeData: RecipeCreate = {
|
||||
name: data.name,
|
||||
category: data.category,
|
||||
finished_product_id: data.finishedProductId,
|
||||
yield_quantity: parseFloat(data.yieldQuantity),
|
||||
yield_unit: data.yieldUnit as MeasurementUnit,
|
||||
prep_time_minutes: data.prepTime ? parseInt(data.prepTime) : null,
|
||||
instructions: data.instructions ? { steps: data.instructions } : null,
|
||||
ingredients: recipeIngredients,
|
||||
};
|
||||
|
||||
await recipesService.createRecipe(currentTenant.id, recipeData);
|
||||
showToast.success('Receta creada exitosamente');
|
||||
onDataChange({ ...data, ingredients: selectedIngredients });
|
||||
onComplete();
|
||||
} catch (err: any) {
|
||||
console.error('Error creating recipe:', err);
|
||||
const errorMessage = err.response?.data?.detail || 'Error al crear la receta';
|
||||
setError(errorMessage);
|
||||
showToast.error(errorMessage);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
onNext();
|
||||
};
|
||||
|
||||
const filteredIngredients = ingredients.filter(ing =>
|
||||
@@ -394,14 +355,215 @@ const IngredientsStep: React.FC<WizardDataProps> = ({ data, onDataChange, onComp
|
||||
|
||||
<div className="flex justify-end gap-3 pt-4 border-t border-[var(--border-primary)]">
|
||||
<button
|
||||
onClick={handleSaveRecipe}
|
||||
disabled={saving || selectedIngredients.length === 0 || loading}
|
||||
onClick={handleContinue}
|
||||
disabled={selectedIngredients.length === 0 || loading}
|
||||
className="px-6 py-2.5 bg-[var(--color-primary)] text-white rounded-lg hover:bg-[var(--color-primary)]/90 disabled:opacity-50 disabled:cursor-not-allowed transition-colors"
|
||||
>
|
||||
Continuar
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
// Step 3: Quality Templates Selection
|
||||
const QualityTemplatesStep: React.FC<WizardDataProps> = ({ data, onDataChange, onComplete }) => {
|
||||
const { currentTenant } = useTenant();
|
||||
const [templates, setTemplates] = useState<QualityCheckTemplateResponse[]>([]);
|
||||
const [selectedTemplateIds, setSelectedTemplateIds] = useState<string[]>(data.selectedTemplates || []);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [saving, setSaving] = useState(false);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
fetchTemplates();
|
||||
}, []);
|
||||
|
||||
const fetchTemplates = async () => {
|
||||
if (!currentTenant?.id) return;
|
||||
setLoading(true);
|
||||
try {
|
||||
const result = await qualityTemplateService.getTemplates(currentTenant.id, { is_active: true });
|
||||
setTemplates(result);
|
||||
} catch (err) {
|
||||
console.error('Error loading quality templates:', err);
|
||||
setError('Error al cargar plantillas de calidad');
|
||||
} finally {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
const toggleTemplate = (templateId: string) => {
|
||||
setSelectedTemplateIds(prev =>
|
||||
prev.includes(templateId)
|
||||
? prev.filter(id => id !== templateId)
|
||||
: [...prev, templateId]
|
||||
);
|
||||
};
|
||||
|
||||
const handleCreateRecipe = async () => {
|
||||
if (!currentTenant?.id) {
|
||||
setError('No se pudo obtener información del tenant');
|
||||
return;
|
||||
}
|
||||
|
||||
setSaving(true);
|
||||
setError(null);
|
||||
|
||||
try {
|
||||
// Prepare recipe ingredients
|
||||
const recipeIngredients: RecipeIngredientCreate[] = data.ingredients.map((ing: any, index: number) => ({
|
||||
ingredient_id: ing.ingredientId,
|
||||
quantity: ing.quantity,
|
||||
unit: ing.unit,
|
||||
ingredient_notes: ing.notes || null,
|
||||
is_optional: false,
|
||||
ingredient_order: index + 1,
|
||||
}));
|
||||
|
||||
// Prepare quality configuration if templates are selected
|
||||
let qualityConfig: RecipeQualityConfiguration | undefined;
|
||||
if (selectedTemplateIds.length > 0) {
|
||||
qualityConfig = {
|
||||
stages: {
|
||||
production: {
|
||||
template_ids: selectedTemplateIds,
|
||||
required_checks: [],
|
||||
optional_checks: [],
|
||||
blocking_on_failure: true,
|
||||
min_quality_score: 7.0,
|
||||
}
|
||||
},
|
||||
overall_quality_threshold: 7.0,
|
||||
critical_stage_blocking: true,
|
||||
auto_create_quality_checks: true,
|
||||
quality_manager_approval_required: false,
|
||||
};
|
||||
}
|
||||
|
||||
const recipeData: RecipeCreate = {
|
||||
name: data.name,
|
||||
category: data.category,
|
||||
finished_product_id: data.finishedProductId,
|
||||
yield_quantity: parseFloat(data.yieldQuantity),
|
||||
yield_unit: data.yieldUnit as MeasurementUnit,
|
||||
prep_time_minutes: data.prepTime ? parseInt(data.prepTime) : null,
|
||||
instructions: data.instructions ? { steps: data.instructions } : null,
|
||||
ingredients: recipeIngredients,
|
||||
quality_check_configuration: qualityConfig,
|
||||
};
|
||||
|
||||
await recipesService.createRecipe(currentTenant.id, recipeData);
|
||||
showToast.success('Receta creada exitosamente');
|
||||
onDataChange({ ...data, selectedTemplates: selectedTemplateIds });
|
||||
onComplete();
|
||||
} catch (err: any) {
|
||||
console.error('Error creating recipe:', err);
|
||||
const errorMessage = err.response?.data?.detail || 'Error al crear la receta';
|
||||
setError(errorMessage);
|
||||
showToast.error(errorMessage);
|
||||
} finally {
|
||||
setSaving(false);
|
||||
}
|
||||
};
|
||||
|
||||
return (
|
||||
<div className="space-y-6">
|
||||
<div className="text-center pb-4 border-b border-[var(--border-primary)]">
|
||||
<ClipboardCheck 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">
|
||||
Plantillas de Calidad (Opcional)
|
||||
</h3>
|
||||
<p className="text-sm text-[var(--text-secondary)]">
|
||||
Selecciona las plantillas de control de calidad que aplicarán a esta receta
|
||||
</p>
|
||||
</div>
|
||||
|
||||
{error && (
|
||||
<div className="p-3 bg-red-50 border border-red-200 rounded-lg text-red-700 text-sm">
|
||||
{error}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{loading ? (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<Loader2 className="w-8 h-8 animate-spin text-[var(--color-primary)]" />
|
||||
<span className="ml-3 text-[var(--text-secondary)]">Cargando plantillas...</span>
|
||||
</div>
|
||||
) : (
|
||||
<>
|
||||
{templates.length === 0 ? (
|
||||
<div className="text-center py-12 border-2 border-dashed border-[var(--border-secondary)] rounded-lg">
|
||||
<ClipboardCheck className="w-12 h-12 mx-auto mb-3 text-[var(--text-tertiary)]" />
|
||||
<p className="text-[var(--text-secondary)] mb-2">No hay plantillas de calidad disponibles</p>
|
||||
<p className="text-sm text-[var(--text-tertiary)]">
|
||||
Puedes crear plantillas desde el wizard principal
|
||||
</p>
|
||||
</div>
|
||||
) : (
|
||||
<div className="space-y-3 max-h-96 overflow-y-auto">
|
||||
{templates.map((template) => (
|
||||
<button
|
||||
key={template.id}
|
||||
onClick={() => toggleTemplate(template.id)}
|
||||
className={`w-full p-4 rounded-lg border-2 transition-all text-left ${
|
||||
selectedTemplateIds.includes(template.id)
|
||||
? 'border-[var(--color-primary)] bg-[var(--color-primary)]/5'
|
||||
: 'border-[var(--border-secondary)] hover:border-[var(--color-primary)]/50'
|
||||
}`}
|
||||
>
|
||||
<div className="flex items-start justify-between">
|
||||
<div className="flex-1">
|
||||
<div className="flex items-center gap-2 mb-1">
|
||||
<h4 className="font-semibold text-[var(--text-primary)]">{template.name}</h4>
|
||||
{template.is_required && (
|
||||
<span className="px-2 py-0.5 text-xs bg-orange-100 text-orange-700 rounded-full">
|
||||
Obligatorio
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
{template.description && (
|
||||
<p className="text-sm text-[var(--text-secondary)] line-clamp-2">
|
||||
{template.description}
|
||||
</p>
|
||||
)}
|
||||
<div className="flex items-center gap-3 mt-2 text-xs text-[var(--text-tertiary)]">
|
||||
<span>Tipo: {template.check_type}</span>
|
||||
{template.frequency_days && (
|
||||
<span>• Cada {template.frequency_days} días</span>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{selectedTemplateIds.includes(template.id) && (
|
||||
<CheckCircle2 className="w-5 h-5 text-[var(--color-primary)] flex-shrink-0 ml-3" />
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{selectedTemplateIds.length > 0 && (
|
||||
<div className="p-4 bg-[var(--color-primary)]/5 rounded-lg border border-[var(--color-primary)]/20">
|
||||
<p className="text-sm text-[var(--text-primary)]">
|
||||
<strong>{selectedTemplateIds.length}</strong> plantilla(s) seleccionada(s)
|
||||
</p>
|
||||
</div>
|
||||
)}
|
||||
</>
|
||||
)}
|
||||
|
||||
{/* Action Buttons */}
|
||||
<div className="flex justify-end gap-3 pt-4 border-t border-[var(--border-primary)]">
|
||||
<button
|
||||
onClick={handleCreateRecipe}
|
||||
disabled={saving || 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"
|
||||
>
|
||||
{saving ? (
|
||||
<>
|
||||
<Loader2 className="w-5 h-5 animate-spin" />
|
||||
Creando...
|
||||
Creando receta...
|
||||
</>
|
||||
) : (
|
||||
<>
|
||||
@@ -418,4 +580,5 @@ const IngredientsStep: React.FC<WizardDataProps> = ({ data, onDataChange, onComp
|
||||
export const RecipeWizardSteps = (data: Record<string, any>, setData: (data: Record<string, any>) => void): WizardStep[] => [
|
||||
{ id: 'recipe-details', title: 'Detalles de la Receta', description: 'Nombre, categoría, rendimiento', component: (props) => <RecipeDetailsStep {...props} data={data} onDataChange={setData} /> },
|
||||
{ id: 'recipe-ingredients', title: 'Ingredientes', description: 'Selección y cantidades', component: (props) => <IngredientsStep {...props} data={data} onDataChange={setData} /> },
|
||||
{ id: 'recipe-quality-templates', title: 'Plantillas de Calidad', description: 'Controles de calidad aplicables', component: (props) => <QualityTemplatesStep {...props} data={data} onDataChange={setData} /> },
|
||||
];
|
||||
|
||||
Reference in New Issue
Block a user