import React, { useState } from 'react'; import { Plus, Calendar, Clock, Users, AlertCircle, Search, Download, Filter } from 'lucide-react'; import { Button, Card, Badge } from '../../../../components/ui'; import { DataTable } from '../../../../components/shared'; import type { DataTableColumn, DataTableFilter, DataTablePagination, DataTableSelection } from '../../../../components/shared'; import { PageHeader } from '../../../../components/layout'; import { ProductionSchedule, BatchTracker, QualityControl } from '../../../../components/domain/production'; const ProductionPage: React.FC = () => { const [activeTab, setActiveTab] = useState('schedule'); const [searchQuery, setSearchQuery] = useState(''); const [filters, setFilters] = useState([]); const [selectedBatches, setSelectedBatches] = useState([]); const [pagination, setPagination] = useState({ page: 1, pageSize: 10, total: 8 // Updated to match the number of mock orders }); const [isLoading, setIsLoading] = useState(false); const mockProductionStats = { dailyTarget: 150, completed: 85, inProgress: 12, pending: 53, efficiency: 78, quality: 94, }; // Handler functions for table actions const handleViewBatch = (batch: any) => { console.log('Ver lote:', batch); // Implement view logic }; const handleEditBatch = (batch: any) => { console.log('Editar lote:', batch); // Implement edit logic }; const handleSearchChange = (query: string) => { setSearchQuery(query); // Implement search logic }; const handleFiltersChange = (newFilters: DataTableFilter[]) => { setFilters(newFilters); // Implement filtering logic }; const handlePageChange = (page: number, pageSize: number) => { setPagination(prev => ({ ...prev, page, pageSize })); // Implement pagination logic }; const handleBatchSelection = (selectedRows: any[]) => { setSelectedBatches(selectedRows); }; const handleExport = (format: 'csv' | 'xlsx') => { console.log(`Exportando en formato ${format}`); // Implement export logic }; const mockProductionOrders = [ { id: '1', recipeName: 'Pan de Molde Integral', quantity: 20, status: 'in_progress', priority: 'high', assignedTo: 'Juan Panadero', startTime: '2024-01-26T06:00:00Z', estimatedCompletion: '2024-01-26T10:00:00Z', progress: 65, }, { id: '2', recipeName: 'Croissants de Mantequilla', quantity: 50, status: 'pending', priority: 'medium', assignedTo: 'María González', startTime: '2024-01-26T08:00:00Z', estimatedCompletion: '2024-01-26T12:00:00Z', progress: 0, }, { id: '3', recipeName: 'Baguettes Francesas', quantity: 30, status: 'completed', priority: 'medium', assignedTo: 'Carlos Ruiz', startTime: '2024-01-26T04:00:00Z', estimatedCompletion: '2024-01-26T08:00:00Z', progress: 100, }, { id: '4', recipeName: 'Tarta de Chocolate', quantity: 5, status: 'pending', priority: 'low', assignedTo: 'Ana Pastelera', startTime: '2024-01-26T10:00:00Z', estimatedCompletion: '2024-01-26T16:00:00Z', progress: 0, }, { id: '5', recipeName: 'Empanadas de Pollo', quantity: 40, status: 'in_progress', priority: 'high', assignedTo: 'Luis Hornero', startTime: '2024-01-26T07:00:00Z', estimatedCompletion: '2024-01-26T11:00:00Z', progress: 45, }, { id: '6', recipeName: 'Donuts Glaseados', quantity: 60, status: 'pending', priority: 'urgent', assignedTo: 'María González', startTime: '2024-01-26T12:00:00Z', estimatedCompletion: '2024-01-26T15:00:00Z', progress: 0, }, { id: '7', recipeName: 'Pan de Centeno', quantity: 25, status: 'completed', priority: 'medium', assignedTo: 'Juan Panadero', startTime: '2024-01-26T05:00:00Z', estimatedCompletion: '2024-01-26T09:00:00Z', progress: 100, }, { id: '8', recipeName: 'Muffins de Arándanos', quantity: 36, status: 'in_progress', priority: 'medium', assignedTo: 'Ana Pastelera', startTime: '2024-01-26T08:30:00Z', estimatedCompletion: '2024-01-26T12:30:00Z', progress: 70, }, ]; const getStatusBadge = (status: string) => { const statusConfig = { pending: { color: 'yellow', text: 'Pendiente' }, in_progress: { color: 'blue', text: 'En Proceso' }, completed: { color: 'green', text: 'Completado' }, cancelled: { color: 'red', text: 'Cancelado' }, }; const config = statusConfig[status as keyof typeof statusConfig]; return {config.text}; }; const getPriorityBadge = (priority: string) => { const priorityConfig = { low: { color: 'gray', text: 'Baja' }, medium: { color: 'yellow', text: 'Media' }, high: { color: 'orange', text: 'Alta' }, urgent: { color: 'red', text: 'Urgente' }, }; const config = priorityConfig[priority as keyof typeof priorityConfig]; return {config.text}; }; const columns: DataTableColumn[] = [ { id: 'recipeName', key: 'recipeName', header: 'Receta', sortable: true, filterable: true, type: 'text', width: 200, cell: (value) => (
{value}
), }, { id: 'quantity', key: 'quantity', header: 'Cantidad', sortable: true, filterable: true, type: 'number', width: 120, align: 'center', cell: (value) => `${value} unidades`, }, { id: 'status', key: 'status', header: 'Estado', sortable: true, filterable: true, type: 'select', width: 130, align: 'center', selectOptions: [ { value: 'pending', label: 'Pendiente' }, { value: 'in_progress', label: 'En Proceso' }, { value: 'completed', label: 'Completado' }, { value: 'cancelled', label: 'Cancelado' } ], cell: (value) => getStatusBadge(value), }, { id: 'priority', key: 'priority', header: 'Prioridad', sortable: true, filterable: true, type: 'select', width: 120, align: 'center', selectOptions: [ { value: 'low', label: 'Baja' }, { value: 'medium', label: 'Media' }, { value: 'high', label: 'Alta' }, { value: 'urgent', label: 'Urgente' } ], cell: (value) => getPriorityBadge(value), }, { id: 'assignedTo', key: 'assignedTo', header: 'Asignado a', sortable: true, filterable: true, type: 'text', width: 180, hideOnMobile: true, cell: (value) => (
{value}
), }, { id: 'progress', key: 'progress', header: 'Progreso', sortable: true, filterable: true, type: 'number', width: 150, align: 'center', hideOnMobile: true, cell: (value) => (
{value}%
), }, { id: 'estimatedCompletion', key: 'estimatedCompletion', header: 'Tiempo Estimado', sortable: true, filterable: true, type: 'date', width: 140, align: 'center', hideOnMobile: true, cell: (value) => new Date(value).toLocaleTimeString('es-ES', { hour: '2-digit', minute: '2-digit' }), }, { id: 'actions', key: 'actions', header: 'Acciones', sortable: false, filterable: false, width: 150, align: 'right', sticky: 'right', cell: (value, row) => (
), }, ]; return (
Nueva Orden de Producción } /> {/* Production Stats */}

Meta Diaria

{mockProductionStats.dailyTarget}

Completado

{mockProductionStats.completed}

En Proceso

{mockProductionStats.inProgress}

Pendiente

{mockProductionStats.pending}

Eficiencia

{mockProductionStats.efficiency}%

Calidad

{mockProductionStats.quality}%

{/* Tabs Navigation */}
{/* Tab Content */} {activeTab === 'schedule' && (

Órdenes de Producción

{selectedBatches.length > 0 && ( )}
row.id }} enableExport={true} onExport={handleExport} density="normal" horizontalScroll={true} emptyStateMessage="No se encontraron órdenes de producción" emptyStateAction={{ label: "Nueva Orden", onClick: () => console.log('Nueva orden de producción') }} onRowClick={(row) => console.log('Ver detalles:', row)} />
)} {activeTab === 'batches' && ( )} {activeTab === 'quality' && ( )}
); }; export default ProductionPage;