Improve frontend 3
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import React from 'react';
|
||||
import { Clock, Timer, CheckCircle, AlertCircle, Package, Play, Pause, X, Edit, Eye, History, Settings } from 'lucide-react';
|
||||
import { Clock, Timer, CheckCircle, AlertCircle, Package, Play, Pause, X, Eye } from 'lucide-react';
|
||||
import { StatusCard, StatusIndicatorConfig } from '../../ui/StatusCard/StatusCard';
|
||||
import { statusColors } from '../../../styles/colors';
|
||||
import { ProductionBatchResponse, ProductionStatus, ProductionPriority } from '../../../api/types/production';
|
||||
@@ -153,28 +153,39 @@ export const ProductionStatusCard: React.FC<ProductionStatusCardProps> = ({
|
||||
const getProductionActions = () => {
|
||||
const actions = [];
|
||||
|
||||
// Debug logging to see what status we're getting
|
||||
console.log('ProductionStatusCard - Batch:', batch.batch_number, 'Status:', batch.status, 'Type:', typeof batch.status);
|
||||
|
||||
// Primary action - View batch details (matches inventory "Ver Detalles")
|
||||
if (onView) {
|
||||
actions.push({
|
||||
label: 'Ver',
|
||||
label: 'Ver Detalles',
|
||||
icon: Eye,
|
||||
variant: 'primary' as const,
|
||||
priority: 'primary' as const,
|
||||
onClick: () => onView(batch)
|
||||
});
|
||||
}
|
||||
|
||||
// Status-specific primary actions
|
||||
if (batch.status === ProductionStatus.PENDING && onStart) {
|
||||
actions.push({
|
||||
label: 'Iniciar',
|
||||
label: 'Iniciar Producción',
|
||||
icon: Play,
|
||||
priority: 'primary' as const,
|
||||
priority: 'secondary' as const,
|
||||
highlighted: true,
|
||||
onClick: () => onStart(batch)
|
||||
});
|
||||
}
|
||||
|
||||
if (batch.status === ProductionStatus.IN_PROGRESS) {
|
||||
if (onComplete) {
|
||||
actions.push({
|
||||
label: 'Completar',
|
||||
icon: CheckCircle,
|
||||
priority: 'secondary' as const,
|
||||
highlighted: true,
|
||||
onClick: () => onComplete(batch)
|
||||
});
|
||||
}
|
||||
|
||||
if (onPause) {
|
||||
actions.push({
|
||||
label: 'Pausar',
|
||||
@@ -183,75 +194,39 @@ export const ProductionStatusCard: React.FC<ProductionStatusCardProps> = ({
|
||||
onClick: () => onPause(batch)
|
||||
});
|
||||
}
|
||||
|
||||
if (onComplete) {
|
||||
actions.push({
|
||||
label: 'Completar',
|
||||
icon: CheckCircle,
|
||||
priority: 'primary' as const,
|
||||
onClick: () => onComplete(batch)
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if (batch.status === ProductionStatus.ON_HOLD && onStart) {
|
||||
actions.push({
|
||||
label: 'Reanudar',
|
||||
icon: Play,
|
||||
priority: 'primary' as const,
|
||||
priority: 'secondary' as const,
|
||||
highlighted: true,
|
||||
onClick: () => onStart(batch)
|
||||
});
|
||||
}
|
||||
|
||||
if (batch.status === ProductionStatus.QUALITY_CHECK && onQualityCheck) {
|
||||
console.log('ProductionStatusCard - Adding quality check button for batch:', batch.batch_number);
|
||||
actions.push({
|
||||
label: 'Calidad',
|
||||
label: 'Control de Calidad',
|
||||
icon: Package,
|
||||
priority: 'primary' as const,
|
||||
priority: 'secondary' as const,
|
||||
highlighted: true,
|
||||
onClick: () => onQualityCheck(batch)
|
||||
});
|
||||
} else {
|
||||
console.log('ProductionStatusCard - Quality check condition not met:', {
|
||||
batchNumber: batch.batch_number,
|
||||
status: batch.status,
|
||||
expectedStatus: ProductionStatus.QUALITY_CHECK,
|
||||
hasOnQualityCheck: !!onQualityCheck,
|
||||
statusMatch: batch.status === ProductionStatus.QUALITY_CHECK
|
||||
});
|
||||
}
|
||||
|
||||
if (onEdit && (batch.status === ProductionStatus.PENDING || batch.status === ProductionStatus.ON_HOLD)) {
|
||||
actions.push({
|
||||
label: 'Editar',
|
||||
icon: Edit,
|
||||
priority: 'secondary' as const,
|
||||
onClick: () => onEdit(batch)
|
||||
});
|
||||
}
|
||||
|
||||
// Cancel action for non-completed batches
|
||||
if (onCancel && batch.status !== ProductionStatus.COMPLETED && batch.status !== ProductionStatus.CANCELLED) {
|
||||
actions.push({
|
||||
label: 'Cancelar',
|
||||
icon: X,
|
||||
priority: 'tertiary' as const,
|
||||
priority: 'secondary' as const,
|
||||
destructive: true,
|
||||
onClick: () => onCancel(batch)
|
||||
});
|
||||
}
|
||||
|
||||
if (onViewHistory) {
|
||||
actions.push({
|
||||
label: 'Historial',
|
||||
icon: History,
|
||||
priority: 'tertiary' as const,
|
||||
onClick: () => onViewHistory(batch)
|
||||
});
|
||||
}
|
||||
|
||||
// Debug logging to see final actions array
|
||||
console.log('ProductionStatusCard - Final actions array for batch', batch.batch_number, ':', actions);
|
||||
|
||||
return actions;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user