Improve the frontend 3
This commit is contained in:
@@ -7,7 +7,7 @@ import { formatters } from '../../../../components/ui/Stats/StatsPresets';
|
||||
import { useIngredients } from '../../../../api/hooks/inventory';
|
||||
import { useTenantId } from '../../../../hooks/useTenantId';
|
||||
import { ProductType, ProductCategory, IngredientResponse } from '../../../../api/types/inventory';
|
||||
import { useToast } from '../../../../hooks/ui/useToast';
|
||||
import { showToast } from '../../../../utils/toast';
|
||||
import { usePOSConfigurationData, usePOSConfigurationManager, usePOSTransactions, usePOSTransactionsDashboard, usePOSTransaction } from '../../../../api/hooks/pos';
|
||||
import { POSConfiguration } from '../../../../api/types/pos';
|
||||
import { posService } from '../../../../api/services/pos';
|
||||
@@ -546,7 +546,7 @@ const POSPage: React.FC = () => {
|
||||
const [testingConnection, setTestingConnection] = useState<string | null>(null);
|
||||
|
||||
const tenantId = useTenantId();
|
||||
const { addToast } = useToast();
|
||||
|
||||
|
||||
// POS Configuration hooks
|
||||
const posData = usePOSConfigurationData(tenantId);
|
||||
@@ -674,12 +674,12 @@ const POSPage: React.FC = () => {
|
||||
});
|
||||
|
||||
if (response.success) {
|
||||
addToast('Conexión exitosa', { type: 'success' });
|
||||
showToast.success('Conexión exitosa');
|
||||
} else {
|
||||
addToast(`Error en la conexión: ${response.message || 'Error desconocido'}`, { type: 'error' });
|
||||
showToast.error(`Error en la conexión: ${response.message || 'Error desconocido'}`);
|
||||
}
|
||||
} catch (error) {
|
||||
addToast('Error al probar la conexión', { type: 'error' });
|
||||
showToast.error('Error al probar la conexión');
|
||||
} finally {
|
||||
setTestingConnection(null);
|
||||
}
|
||||
@@ -695,10 +695,10 @@ const POSPage: React.FC = () => {
|
||||
tenant_id: tenantId,
|
||||
config_id: configId,
|
||||
});
|
||||
addToast('Configuración eliminada correctamente', { type: 'success' });
|
||||
showToast.success('Configuración eliminada correctamente');
|
||||
loadPosConfigurations();
|
||||
} catch (error) {
|
||||
addToast('Error al eliminar la configuración', { type: 'error' });
|
||||
showToast.error('Error al eliminar la configuración');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -762,7 +762,7 @@ const POSPage: React.FC = () => {
|
||||
});
|
||||
|
||||
setCart([]);
|
||||
addToast('Venta procesada exitosamente', { type: 'success' });
|
||||
showToast.success('Venta procesada exitosamente');
|
||||
};
|
||||
|
||||
// Loading and error states
|
||||
|
||||
@@ -15,7 +15,7 @@ import { useTriggerDailyScheduler } from '../../../../api';
|
||||
import type { PurchaseOrderStatus, PurchaseOrderPriority, PurchaseOrderDetail } from '../../../../api/services/purchase_orders';
|
||||
import { useTenantStore } from '../../../../stores/tenant.store';
|
||||
import { useUserById } from '../../../../api/hooks/user';
|
||||
import toast from 'react-hot-toast';
|
||||
import { showToast } from '../../../../utils/toast';
|
||||
|
||||
const ProcurementPage: React.FC = () => {
|
||||
// State
|
||||
@@ -59,7 +59,6 @@ const ProcurementPage: React.FC = () => {
|
||||
const approvePOMutation = useApprovePurchaseOrder();
|
||||
const rejectPOMutation = useRejectPurchaseOrder();
|
||||
const updatePOMutation = useUpdatePurchaseOrder();
|
||||
const triggerSchedulerMutation = useTriggerDailyScheduler();
|
||||
|
||||
// Filter POs
|
||||
const filteredPOs = useMemo(() => {
|
||||
@@ -129,11 +128,11 @@ const ProcurementPage: React.FC = () => {
|
||||
poId: po.id,
|
||||
data: { status: 'SENT_TO_SUPPLIER' }
|
||||
});
|
||||
toast.success('Orden enviada al proveedor');
|
||||
showToast.success('Orden enviada al proveedor');
|
||||
refetchPOs();
|
||||
} catch (error) {
|
||||
console.error('Error sending PO to supplier:', error);
|
||||
toast.error('Error al enviar orden al proveedor');
|
||||
showToast.error('Error al enviar orden al proveedor');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -144,11 +143,11 @@ const ProcurementPage: React.FC = () => {
|
||||
poId: po.id,
|
||||
data: { status: 'CONFIRMED' }
|
||||
});
|
||||
toast.success('Orden confirmada');
|
||||
showToast.success('Orden confirmada');
|
||||
refetchPOs();
|
||||
} catch (error) {
|
||||
console.error('Error confirming PO:', error);
|
||||
toast.error('Error al confirmar orden');
|
||||
showToast.error('Error al confirmar orden');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -162,10 +161,10 @@ const ProcurementPage: React.FC = () => {
|
||||
poId: selectedPOId,
|
||||
notes: approvalNotes || undefined
|
||||
});
|
||||
toast.success('Orden aprobada exitosamente');
|
||||
showToast.success('Orden aprobada exitosamente');
|
||||
} else {
|
||||
if (!approvalNotes.trim()) {
|
||||
toast.error('Debes proporcionar una razón para rechazar');
|
||||
showToast.error('Debes proporcionar una razón para rechazar');
|
||||
return;
|
||||
}
|
||||
await rejectPOMutation.mutateAsync({
|
||||
@@ -173,7 +172,7 @@ const ProcurementPage: React.FC = () => {
|
||||
poId: selectedPOId,
|
||||
reason: approvalNotes
|
||||
});
|
||||
toast.success('Orden rechazada');
|
||||
showToast.success('Orden rechazada');
|
||||
}
|
||||
setShowApprovalModal(false);
|
||||
setShowDetailsModal(false);
|
||||
@@ -181,18 +180,18 @@ const ProcurementPage: React.FC = () => {
|
||||
refetchPOs();
|
||||
} catch (error) {
|
||||
console.error('Error in approval action:', error);
|
||||
toast.error('Error al procesar aprobación');
|
||||
showToast.error('Error al procesar aprobación');
|
||||
}
|
||||
};
|
||||
|
||||
const handleTriggerScheduler = async () => {
|
||||
try {
|
||||
await triggerSchedulerMutation.mutateAsync(tenantId);
|
||||
toast.success('Scheduler ejecutado exitosamente');
|
||||
showToast.success('Scheduler ejecutado exitosamente');
|
||||
refetchPOs();
|
||||
} catch (error) {
|
||||
console.error('Error triggering scheduler:', error);
|
||||
toast.error('Error al ejecutar scheduler');
|
||||
showToast.error('Error al ejecutar scheduler');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -715,16 +714,6 @@ const ProcurementPage: React.FC = () => {
|
||||
title="Órdenes de Compra"
|
||||
description="Gestiona órdenes de compra y aprovisionamiento"
|
||||
actions={[
|
||||
{
|
||||
id: 'trigger-scheduler',
|
||||
label: triggerSchedulerMutation.isPending ? 'Ejecutando...' : 'Ejecutar Scheduler',
|
||||
icon: Play,
|
||||
onClick: handleTriggerScheduler,
|
||||
variant: 'outline',
|
||||
size: 'sm',
|
||||
disabled: triggerSchedulerMutation.isPending,
|
||||
loading: triggerSchedulerMutation.isPending
|
||||
},
|
||||
{
|
||||
id: 'create-po',
|
||||
label: 'Nueva Orden',
|
||||
@@ -857,7 +846,7 @@ const ProcurementPage: React.FC = () => {
|
||||
onSuccess={() => {
|
||||
setShowCreatePOModal(false);
|
||||
refetchPOs();
|
||||
toast.success('Orden de compra creada exitosamente');
|
||||
showToast.success('Orden de compra creada exitosamente');
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
|
||||
@@ -26,7 +26,7 @@ import {
|
||||
} from '../../../../api';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import { ProcessStage } from '../../../../api/types/qualityTemplates';
|
||||
import toast from 'react-hot-toast';
|
||||
import { showToast } from '../../../../utils/toast';
|
||||
|
||||
const ProductionPage: React.FC = () => {
|
||||
const [searchQuery, setSearchQuery] = useState('');
|
||||
@@ -58,7 +58,6 @@ const ProductionPage: React.FC = () => {
|
||||
// Mutations
|
||||
const createBatchMutation = useCreateProductionBatch();
|
||||
const updateBatchStatusMutation = useUpdateBatchStatus();
|
||||
const triggerSchedulerMutation = useTriggerProductionScheduler();
|
||||
|
||||
// Handlers
|
||||
const handleCreateBatch = async (batchData: ProductionBatchCreate) => {
|
||||
@@ -76,10 +75,10 @@ const ProductionPage: React.FC = () => {
|
||||
const handleTriggerScheduler = async () => {
|
||||
try {
|
||||
await triggerSchedulerMutation.mutateAsync(tenantId);
|
||||
toast.success('Scheduler ejecutado exitosamente');
|
||||
showToast.success('Scheduler ejecutado exitosamente');
|
||||
} catch (error) {
|
||||
console.error('Error triggering scheduler:', error);
|
||||
toast.error('Error al ejecutar scheduler');
|
||||
showToast.error('Error al ejecutar scheduler');
|
||||
}
|
||||
};
|
||||
|
||||
@@ -300,16 +299,6 @@ const ProductionPage: React.FC = () => {
|
||||
title="Gestión de Producción"
|
||||
description="Planifica y controla la producción diaria de tu panadería"
|
||||
actions={[
|
||||
{
|
||||
id: 'trigger-scheduler',
|
||||
label: triggerSchedulerMutation.isPending ? 'Ejecutando...' : 'Ejecutar Scheduler',
|
||||
icon: Play,
|
||||
onClick: handleTriggerScheduler,
|
||||
variant: 'outline',
|
||||
size: 'sm',
|
||||
disabled: triggerSchedulerMutation.isPending,
|
||||
loading: triggerSchedulerMutation.isPending
|
||||
},
|
||||
{
|
||||
id: 'create-batch',
|
||||
label: 'Nueva Orden de Producción',
|
||||
@@ -731,4 +720,4 @@ const ProductionPage: React.FC = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default ProductionPage;
|
||||
export default ProductionPage;
|
||||
|
||||
Reference in New Issue
Block a user